2017-09-15 13:19:27 +02:00
|
|
|
|
// swad_project.c: projects (final degree projects, thesis)
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
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.
|
2020-01-01 14:53:57 +01:00
|
|
|
|
Copyright (C) 1999-2020 Antonio Ca<EFBFBD>as Vargas
|
2017-09-15 13:19:27 +02:00
|
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU Affero General Public License as
|
|
|
|
|
published by the Free Software Foundation, either version 3 of the
|
|
|
|
|
License, or (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU Affero General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Affero General Public License
|
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************************* Headers ***********************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2018-10-24 23:03:11 +02:00
|
|
|
|
#define _GNU_SOURCE // For asprintf
|
2017-09-15 13:19:27 +02:00
|
|
|
|
#include <linux/limits.h> // For PATH_MAX
|
2019-12-29 12:39:00 +01:00
|
|
|
|
#include <stddef.h> // For NULL
|
2018-10-24 23:03:11 +02:00
|
|
|
|
#include <stdio.h> // For asprintf
|
2017-09-15 13:19:27 +02:00
|
|
|
|
#include <stdlib.h> // For calloc
|
|
|
|
|
#include <string.h> // For string functions
|
|
|
|
|
|
|
|
|
|
#include "swad_box.h"
|
|
|
|
|
#include "swad_database.h"
|
2018-11-09 20:47:39 +01:00
|
|
|
|
#include "swad_form.h"
|
2017-09-15 13:19:27 +02:00
|
|
|
|
#include "swad_global.h"
|
2019-10-23 19:05:05 +02:00
|
|
|
|
#include "swad_HTML.h"
|
2017-09-24 13:49:22 +02:00
|
|
|
|
#include "swad_ID.h"
|
2017-09-15 13:19:27 +02:00
|
|
|
|
#include "swad_notification.h"
|
|
|
|
|
#include "swad_pagination.h"
|
|
|
|
|
#include "swad_parameter.h"
|
|
|
|
|
#include "swad_photo.h"
|
|
|
|
|
#include "swad_project.h"
|
2019-09-28 15:03:22 +02:00
|
|
|
|
#include "swad_role.h"
|
2019-03-26 11:53:21 +01:00
|
|
|
|
#include "swad_setting.h"
|
2017-09-15 13:19:27 +02:00
|
|
|
|
#include "swad_string.h"
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************** External global variables from others modules ****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
extern struct Globals Gbl;
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2017-09-24 18:51:56 +02:00
|
|
|
|
/************************* Private constants and types ***********************/
|
2017-09-15 13:19:27 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2017-10-10 12:37:09 +02:00
|
|
|
|
/***** Parameters used to filter listing of projects *****/
|
|
|
|
|
#define Prj_PARAM_PRE_NON_NAME "PreNon"
|
|
|
|
|
#define Prj_PARAM_HID_VIS_NAME "HidVis"
|
2019-10-16 01:11:42 +02:00
|
|
|
|
#define Prj_PARAM_FAULTIN_NAME "Faulti"
|
2017-10-10 01:26:45 +02:00
|
|
|
|
|
2017-10-10 12:37:09 +02:00
|
|
|
|
/***** Type of view when writing one project *****/
|
2017-09-20 23:25:55 +02:00
|
|
|
|
typedef enum
|
|
|
|
|
{
|
|
|
|
|
Prj_LIST_PROJECTS,
|
2017-10-06 01:20:05 +02:00
|
|
|
|
Prj_FILE_BROWSER_PROJECT,
|
2017-09-20 23:25:55 +02:00
|
|
|
|
Prj_PRINT_ONE_PROJECT,
|
|
|
|
|
Prj_EDIT_ONE_PROJECT,
|
|
|
|
|
} Prj_ProjectView_t;
|
|
|
|
|
|
2017-10-10 12:37:09 +02:00
|
|
|
|
/***** User roles are shown in this order *****/
|
2017-10-10 01:26:45 +02:00
|
|
|
|
static const Prj_RoleInProject_t Prj_RolesToShow[] =
|
2017-10-01 00:48:36 +02:00
|
|
|
|
{
|
|
|
|
|
Prj_ROLE_TUT, // Tutor
|
|
|
|
|
Prj_ROLE_STD, // Student
|
2019-04-11 09:55:35 +02:00
|
|
|
|
Prj_ROLE_EVL, // Evaluator
|
2017-10-01 00:48:36 +02:00
|
|
|
|
};
|
2017-10-10 12:37:09 +02:00
|
|
|
|
static const unsigned Brw_NUM_ROLES_TO_SHOW = sizeof (Prj_RolesToShow) /
|
|
|
|
|
sizeof (Prj_RolesToShow[0]);
|
2017-10-01 00:48:36 +02:00
|
|
|
|
|
2017-10-10 12:37:09 +02:00
|
|
|
|
/***** Enum field in database for types of proposal *****/
|
2017-10-10 01:26:45 +02:00
|
|
|
|
static const char *Prj_Proposal_DB[Prj_NUM_PROPOSAL_TYPES] =
|
2017-10-02 01:16:10 +02:00
|
|
|
|
{
|
2019-11-21 01:27:17 +01:00
|
|
|
|
[Prj_PROPOSAL_NEW ] = "new",
|
|
|
|
|
[Prj_PROPOSAL_MODIFIED ] = "modified",
|
|
|
|
|
[Prj_PROPOSAL_UNMODIFIED] = "unmodified",
|
2017-10-02 01:16:10 +02:00
|
|
|
|
};
|
|
|
|
|
|
2019-10-25 22:48:34 +02:00
|
|
|
|
/***** Assigned/non-assigned project *****/
|
|
|
|
|
static const char *AssignedNonassigImage[Prj_NUM_ASSIGNED_NONASSIG] =
|
2017-10-10 01:26:45 +02:00
|
|
|
|
{
|
2019-11-21 01:27:17 +01:00
|
|
|
|
[Prj_ASSIGNED] = "user.svg",
|
|
|
|
|
[Prj_NONASSIG] = "user-slash.svg",
|
2017-10-10 01:26:45 +02:00
|
|
|
|
};
|
2019-04-18 11:00:28 +02:00
|
|
|
|
|
|
|
|
|
/***** Locked/unlocked project edition *****/
|
|
|
|
|
static const char *Prj_LockIcons[Prj_NUM_LOCKED_UNLOCKED] =
|
2019-04-17 12:40:04 +02:00
|
|
|
|
{
|
2019-11-21 01:27:17 +01:00
|
|
|
|
[Prj_LOCKED ] = "lock.svg",
|
|
|
|
|
[Prj_UNLOCKED] = "unlock.svg",
|
2019-04-17 12:40:04 +02:00
|
|
|
|
};
|
2019-04-18 11:00:28 +02:00
|
|
|
|
static const Act_Action_t Prj_LockActions[Prj_NUM_LOCKED_UNLOCKED] =
|
|
|
|
|
{
|
2019-11-21 01:27:17 +01:00
|
|
|
|
[Prj_LOCKED ] = ActUnlPrj,
|
|
|
|
|
[Prj_UNLOCKED] = ActLckPrj,
|
2019-04-18 11:00:28 +02:00
|
|
|
|
};
|
|
|
|
|
|
2019-11-15 03:34:48 +01:00
|
|
|
|
/***** List of users to select one or more members
|
|
|
|
|
to be added to a project *****/
|
|
|
|
|
struct SelectedUsrs Prj_MembersToAdd =
|
|
|
|
|
{
|
|
|
|
|
.List =
|
|
|
|
|
{
|
|
|
|
|
NULL, // Rol_UNK
|
|
|
|
|
NULL, // Rol_GST
|
|
|
|
|
NULL, // Rol_USR
|
|
|
|
|
NULL, // Rol_STD
|
|
|
|
|
NULL, // Rol_NET
|
|
|
|
|
NULL, // Rol_TCH
|
|
|
|
|
NULL, // Rol_DEG_ADM
|
|
|
|
|
NULL, // Rol_CTR_ADM
|
|
|
|
|
NULL, // Rol_INS_ADM
|
|
|
|
|
NULL, // Rol_SYS_ADM
|
|
|
|
|
},
|
|
|
|
|
.Filled = false,
|
|
|
|
|
.ParamSuffix = "Member",
|
|
|
|
|
.Option = Usr_OPTION_UNKNOWN,
|
|
|
|
|
};
|
|
|
|
|
|
2017-09-15 13:19:27 +02:00
|
|
|
|
/*****************************************************************************/
|
2019-10-17 00:18:31 +02:00
|
|
|
|
/******************************* Private types *******************************/
|
2017-09-15 13:19:27 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2019-10-17 00:18:31 +02:00
|
|
|
|
struct Prj_Faults
|
|
|
|
|
{
|
|
|
|
|
bool WrongTitle;
|
|
|
|
|
bool WrongDescription;
|
|
|
|
|
bool WrongNumStds;
|
2019-10-25 01:15:11 +02:00
|
|
|
|
bool WrongAssigned;
|
2019-10-17 00:18:31 +02:00
|
|
|
|
};
|
|
|
|
|
|
2017-09-15 13:19:27 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************************** Private prototypes ****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2019-11-14 09:39:21 +01:00
|
|
|
|
static void Prj_ReqUsrsToSelect (void);
|
2019-11-15 03:34:48 +01:00
|
|
|
|
static void Prj_GetSelectedUsrsAndShowTheirPrjs (void);
|
|
|
|
|
static void Prj_ShowProjects (void);
|
|
|
|
|
static void Prj_ShowPrjsInCurrentPage (void);
|
2017-09-29 15:05:23 +02:00
|
|
|
|
|
2017-10-10 12:37:09 +02:00
|
|
|
|
static void Prj_ShowFormToFilterByMy_All (void);
|
2019-10-25 22:48:34 +02:00
|
|
|
|
static void Prj_ShowFormToFilterByAssign (void);
|
2017-10-10 12:37:09 +02:00
|
|
|
|
static void Prj_ShowFormToFilterByHidden (void);
|
2019-10-16 01:11:42 +02:00
|
|
|
|
static void Prj_ShowFormToFilterByWarning (void);
|
2017-10-10 12:37:09 +02:00
|
|
|
|
static void Prj_ShowFormToFilterByDpt (void);
|
2017-10-10 01:26:45 +02:00
|
|
|
|
|
|
|
|
|
static void Prj_PutCurrentParams (void);
|
2019-10-25 01:15:11 +02:00
|
|
|
|
static void Prj_PutHiddenParamAssign (unsigned Assign);
|
|
|
|
|
static void Prj_PutHiddenParamHidden (unsigned Hidden);
|
2019-10-16 01:11:42 +02:00
|
|
|
|
static void Prj_PutHiddenParamFaulti (unsigned Faulti);
|
2017-10-10 12:37:09 +02:00
|
|
|
|
static void Prj_PutHiddenParamDptCod (long DptCod);
|
2017-10-10 01:26:45 +02:00
|
|
|
|
static void Prj_GetHiddenParamPreNon (void);
|
|
|
|
|
static void Prj_GetHiddenParamHidVis (void);
|
2019-10-16 01:11:42 +02:00
|
|
|
|
static void Prj_GetHiddenParamFaulti (void);
|
2017-10-10 12:37:09 +02:00
|
|
|
|
static void Prj_GetHiddenParamDptCod (void);
|
2017-10-10 01:26:45 +02:00
|
|
|
|
static void Prj_GetParams (void);
|
2019-11-12 00:31:41 +01:00
|
|
|
|
static void Prj_GetParamWho (void);
|
2017-09-29 15:05:23 +02:00
|
|
|
|
|
2017-10-10 18:25:59 +02:00
|
|
|
|
static void Prj_ShowProjectsHead (Prj_ProjectView_t ProjectView);
|
2017-09-24 13:35:19 +02:00
|
|
|
|
static void Prj_ShowTableAllProjectsHead (void);
|
2017-09-15 13:19:27 +02:00
|
|
|
|
static bool Prj_CheckIfICanCreateProjects (void);
|
|
|
|
|
static void Prj_PutIconsListProjects (void);
|
|
|
|
|
static void Prj_PutIconToCreateNewPrj (void);
|
|
|
|
|
static void Prj_PutButtonToCreateNewPrj (void);
|
2017-09-23 21:36:08 +02:00
|
|
|
|
static void Prj_PutIconToShowAllData (void);
|
2019-04-18 14:06:00 +02:00
|
|
|
|
|
2017-10-10 18:25:59 +02:00
|
|
|
|
static void Prj_ShowOneProject (unsigned NumIndex,struct Project *Prj,
|
|
|
|
|
Prj_ProjectView_t ProjectView);
|
2019-10-17 00:18:31 +02:00
|
|
|
|
static bool Prj_CheckIfPrjIsFaulty (long PrjCod,struct Prj_Faults *Faults);
|
2019-10-14 02:21:41 +02:00
|
|
|
|
static void Prj_PutWarningIcon (void);
|
2017-10-01 18:44:50 +02:00
|
|
|
|
static void Prj_PutIconToToggleProject (unsigned UniqueId,
|
|
|
|
|
const char *Icon,const char *Text);
|
2017-09-24 12:31:48 +02:00
|
|
|
|
static void Prj_ShowTableAllProjectsOneRow (struct Project *Prj);
|
2017-09-22 00:26:14 +02:00
|
|
|
|
static void Prj_ShowOneProjectDepartment (const struct Project *Prj,
|
|
|
|
|
Prj_ProjectView_t ProjectView);
|
2017-09-24 12:31:48 +02:00
|
|
|
|
static void Prj_ShowTableAllProjectsDepartment (const struct Project *Prj);
|
|
|
|
|
static void Prj_ShowOneProjectTxtField (struct Project *Prj,
|
|
|
|
|
Prj_ProjectView_t ProjectView,
|
2017-10-01 18:44:50 +02:00
|
|
|
|
const char *id,unsigned UniqueId,
|
2019-10-14 02:21:41 +02:00
|
|
|
|
const char *Label,char *TxtField,
|
|
|
|
|
bool Warning);
|
2017-09-24 12:31:48 +02:00
|
|
|
|
static void Prj_ShowTableAllProjectsTxtField (struct Project *Prj,
|
|
|
|
|
char *TxtField);
|
2017-09-24 18:51:56 +02:00
|
|
|
|
static void Prj_ShowOneProjectURL (const struct Project *Prj,
|
2017-10-01 18:44:50 +02:00
|
|
|
|
Prj_ProjectView_t ProjectView,
|
|
|
|
|
const char *id,unsigned UniqueId);
|
2017-09-24 18:51:56 +02:00
|
|
|
|
static void Prj_ShowTableAllProjectsURL (const struct Project *Prj);
|
2017-10-01 00:48:36 +02:00
|
|
|
|
static void Prj_ShowOneProjectMembers (struct Project *Prj,
|
|
|
|
|
Prj_ProjectView_t ProjectView);
|
|
|
|
|
static void Prj_ShowOneProjectMembersWithARole (const struct Project *Prj,
|
|
|
|
|
Prj_ProjectView_t ProjectView,
|
|
|
|
|
Prj_RoleInProject_t RoleInProject);
|
|
|
|
|
static void Prj_ShowTableAllProjectsMembersWithARole (const struct Project *Prj,
|
|
|
|
|
Prj_RoleInProject_t RoleInProject);
|
|
|
|
|
|
2019-10-14 00:45:46 +02:00
|
|
|
|
static unsigned Prj_GetNumUsrsInPrj (long PrjCod,Prj_RoleInProject_t RoleInProject);
|
2017-09-24 13:08:26 +02:00
|
|
|
|
static unsigned Prj_GetUsrsInPrj (long PrjCod,Prj_RoleInProject_t RoleInProject,
|
|
|
|
|
MYSQL_RES **mysql_res);
|
2017-09-24 12:31:48 +02:00
|
|
|
|
|
2017-10-08 16:12:58 +02:00
|
|
|
|
static Prj_RoleInProject_t Prj_ConvertUnsignedStrToRoleInProject (const char *UnsignedStr);
|
|
|
|
|
|
2019-04-11 09:55:35 +02:00
|
|
|
|
static void Prj_ReqAddUsrs (Prj_RoleInProject_t RoleInProject);
|
|
|
|
|
static void Prj_AddStds (void);
|
|
|
|
|
static void Prj_AddTuts (void);
|
|
|
|
|
static void Prj_AddEvls (void);
|
|
|
|
|
static void Prj_AddUsrsToProject (Prj_RoleInProject_t RoleInProject);
|
2017-09-22 00:56:17 +02:00
|
|
|
|
static void Prj_ReqRemUsrFromPrj (Prj_RoleInProject_t RoleInProject);
|
2017-09-23 15:24:22 +02:00
|
|
|
|
static void Prj_RemUsrFromPrj (Prj_RoleInProject_t RoleInProject);
|
2017-09-20 15:02:58 +02:00
|
|
|
|
|
2017-09-17 16:58:09 +02:00
|
|
|
|
static void Prj_GetParamPrjOrder (void);
|
2017-09-15 13:19:27 +02:00
|
|
|
|
|
2019-04-17 12:40:04 +02:00
|
|
|
|
static void Prj_PutFormsToRemEditOnePrj (const struct Project *Prj,
|
2019-04-20 13:37:01 +02:00
|
|
|
|
const char *Anchor,
|
2017-10-08 16:12:58 +02:00
|
|
|
|
bool ICanViewProjectFiles);
|
2017-09-24 18:51:56 +02:00
|
|
|
|
|
2019-04-18 11:10:39 +02:00
|
|
|
|
static bool Prj_CheckIfICanEditProject (const struct Project *Prj);
|
2017-09-24 18:51:56 +02:00
|
|
|
|
|
2019-11-13 09:49:52 +01:00
|
|
|
|
static void Prj_GetListProjects (void);
|
|
|
|
|
|
2017-09-15 13:19:27 +02:00
|
|
|
|
static void Prj_ResetProject (struct Project *Prj);
|
2017-09-19 01:12:05 +02:00
|
|
|
|
|
2017-09-21 00:40:09 +02:00
|
|
|
|
static void Prj_RequestCreatOrEditPrj (long PrjCod);
|
2017-09-25 00:33:57 +02:00
|
|
|
|
static void Prj_PutFormProject (struct Project *Prj,bool ItsANewProject);
|
2017-09-20 23:25:55 +02:00
|
|
|
|
static void Prj_EditOneProjectTxtArea (const char *Id,
|
2017-09-23 15:39:21 +02:00
|
|
|
|
const char *Label,char *TxtField,
|
2019-10-14 02:21:41 +02:00
|
|
|
|
unsigned NumRows,bool Required);
|
2017-09-20 23:25:55 +02:00
|
|
|
|
|
2017-09-19 01:12:05 +02:00
|
|
|
|
static void Prj_CreateProject (struct Project *Prj);
|
|
|
|
|
static void Prj_UpdateProject (struct Project *Prj);
|
2017-09-15 13:19:27 +02:00
|
|
|
|
|
2019-10-25 22:48:34 +02:00
|
|
|
|
static bool Prj_CheckIfICanConfigAllProjects (void);
|
|
|
|
|
static void Prj_GetConfigPrjFromDB (void);
|
|
|
|
|
static void Prj_GetConfigFromRow (MYSQL_ROW row);
|
|
|
|
|
static bool Prj_GetEditableFromForm (void);
|
|
|
|
|
static void Prj_PutIconsToLockUnlockAllProjects (void);
|
|
|
|
|
|
|
|
|
|
static void Prj_FormLockUnlock (const struct Project *Prj);
|
|
|
|
|
static void Prj_PutIconOffLockedUnlocked (const struct Project *Prj);
|
|
|
|
|
|
|
|
|
|
static void Prj_LockProjectEditionInDB (long PrjCod);
|
|
|
|
|
static void Prj_UnlockProjectEditionInDB (long PrjCod);
|
|
|
|
|
|
2019-11-14 09:39:21 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/**************************** List users to select ***************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Prj_ListUsrsToSelect (void)
|
|
|
|
|
{
|
|
|
|
|
/***** Get parameters *****/
|
|
|
|
|
Prj_GetParams ();
|
|
|
|
|
|
|
|
|
|
/***** Show list of users to select some of them *****/
|
|
|
|
|
Prj_ReqUsrsToSelect ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void Prj_ReqUsrsToSelect (void)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Hlp_ASSESSMENT_Projects;
|
|
|
|
|
extern const char *Txt_Projects;
|
|
|
|
|
extern const char *Txt_View_projects;
|
|
|
|
|
|
|
|
|
|
/***** List users to select some of them *****/
|
2019-11-15 03:34:48 +01:00
|
|
|
|
Usr_PutFormToSelectUsrsToGoToAct (&Gbl.Usrs.Selected,
|
|
|
|
|
ActSeePrj,Prj_PutCurrentParams,
|
2019-11-14 09:39:21 +01:00
|
|
|
|
Txt_Projects,
|
|
|
|
|
Hlp_ASSESSMENT_Projects,
|
2019-12-09 11:50:03 +01:00
|
|
|
|
Txt_View_projects,
|
|
|
|
|
false); // Do not put form with date range
|
2019-11-14 09:39:21 +01:00
|
|
|
|
}
|
|
|
|
|
|
2017-09-15 13:19:27 +02:00
|
|
|
|
/*****************************************************************************/
|
2019-11-15 03:34:48 +01:00
|
|
|
|
/******************* Get parameters and show projects ************************/
|
2017-09-15 13:19:27 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Prj_SeeProjects (void)
|
|
|
|
|
{
|
|
|
|
|
/***** Get parameters *****/
|
2017-10-10 01:26:45 +02:00
|
|
|
|
Prj_GetParams ();
|
2017-09-15 13:19:27 +02:00
|
|
|
|
|
2019-11-13 00:58:35 +01:00
|
|
|
|
/***** Show projects *****/
|
2019-11-15 03:34:48 +01:00
|
|
|
|
Prj_ShowProjects ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************************* Show projects *******************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Prj_ShowProjects (void)
|
|
|
|
|
{
|
2019-11-13 00:58:35 +01:00
|
|
|
|
switch (Gbl.Prjs.Filter.Who)
|
|
|
|
|
{
|
|
|
|
|
case Usr_WHO_ME:
|
|
|
|
|
case Usr_WHO_ALL:
|
2019-11-13 09:49:52 +01:00
|
|
|
|
/* Show my projects / all projects */
|
2019-11-15 03:34:48 +01:00
|
|
|
|
Prj_ShowPrjsInCurrentPage ();
|
2019-11-13 00:58:35 +01:00
|
|
|
|
break;
|
|
|
|
|
case Usr_WHO_SELECTED:
|
2019-11-14 14:34:34 +01:00
|
|
|
|
/* Get selected users and show their projects */
|
2019-11-15 03:34:48 +01:00
|
|
|
|
Prj_GetSelectedUsrsAndShowTheirPrjs ();
|
2019-11-13 00:58:35 +01:00
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-14 02:29:18 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/****** Get and check list of selected users, and show users' projects *******/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2019-11-15 03:34:48 +01:00
|
|
|
|
static void Prj_GetSelectedUsrsAndShowTheirPrjs (void)
|
2019-11-14 02:29:18 +01:00
|
|
|
|
{
|
2019-11-15 03:34:48 +01:00
|
|
|
|
Usr_GetSelectedUsrsAndGoToAct (&Gbl.Usrs.Selected,
|
|
|
|
|
Prj_ShowPrjsInCurrentPage, // when user(s) selected
|
2019-11-14 14:34:34 +01:00
|
|
|
|
Prj_ReqUsrsToSelect); // when no user selected
|
2019-11-13 00:58:35 +01:00
|
|
|
|
}
|
|
|
|
|
|
2017-09-15 13:19:27 +02:00
|
|
|
|
/*****************************************************************************/
|
2019-11-13 09:49:52 +01:00
|
|
|
|
/********************** Show selected projects in a table ********************/
|
2017-09-24 12:31:48 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2019-11-14 09:39:21 +01:00
|
|
|
|
void Prj_ShowTableSelectedPrjs (void)
|
2017-09-24 12:31:48 +02:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_No_projects;
|
|
|
|
|
unsigned NumPrj;
|
|
|
|
|
struct Project Prj;
|
|
|
|
|
|
2017-09-24 18:51:56 +02:00
|
|
|
|
/***** Get parameters *****/
|
2017-10-10 01:26:45 +02:00
|
|
|
|
Prj_GetParams ();
|
2017-09-24 18:51:56 +02:00
|
|
|
|
|
2017-09-24 12:31:48 +02:00
|
|
|
|
/***** Get list of projects *****/
|
|
|
|
|
Prj_GetListProjects ();
|
|
|
|
|
|
|
|
|
|
if (Gbl.Prjs.Num)
|
|
|
|
|
{
|
|
|
|
|
/***** Allocate memory for the project *****/
|
|
|
|
|
Prj_AllocMemProject (&Prj);
|
|
|
|
|
|
|
|
|
|
/***** Table head *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TABLE_BeginWidePadding (2);
|
2017-09-24 13:35:19 +02:00
|
|
|
|
Prj_ShowTableAllProjectsHead ();
|
2017-09-24 12:31:48 +02:00
|
|
|
|
|
|
|
|
|
/***** Write all the projects *****/
|
|
|
|
|
for (NumPrj = 0;
|
2017-09-24 13:08:26 +02:00
|
|
|
|
NumPrj < Gbl.Prjs.Num;
|
2017-09-24 12:31:48 +02:00
|
|
|
|
NumPrj++)
|
|
|
|
|
{
|
|
|
|
|
Prj.PrjCod = Gbl.Prjs.LstPrjCods[NumPrj];
|
|
|
|
|
Prj_ShowTableAllProjectsOneRow (&Prj);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** End table *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TABLE_End ();
|
2017-09-24 12:31:48 +02:00
|
|
|
|
|
|
|
|
|
/***** Free memory of the project *****/
|
|
|
|
|
Prj_FreeMemProject (&Prj);
|
|
|
|
|
}
|
|
|
|
|
else // No projects created
|
2019-02-16 18:25:41 +01:00
|
|
|
|
Ale_ShowAlert (Ale_INFO,Txt_No_projects);
|
2019-04-18 14:06:00 +02:00
|
|
|
|
|
|
|
|
|
/***** Free list of projects *****/
|
|
|
|
|
Prj_FreeListProjects ();
|
2017-09-24 12:31:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2017-09-24 13:35:19 +02:00
|
|
|
|
/****************** Show the projects in current page ************************/
|
2017-09-15 13:19:27 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2019-11-15 03:34:48 +01:00
|
|
|
|
static void Prj_ShowPrjsInCurrentPage (void)
|
2017-09-15 13:19:27 +02:00
|
|
|
|
{
|
2017-09-17 16:58:09 +02:00
|
|
|
|
extern const char *Hlp_ASSESSMENT_Projects;
|
|
|
|
|
extern const char *Txt_Projects;
|
|
|
|
|
extern const char *Txt_No_projects;
|
2017-09-15 13:19:27 +02:00
|
|
|
|
struct Pagination Pagination;
|
2017-09-17 16:58:09 +02:00
|
|
|
|
unsigned NumPrj;
|
2017-10-10 18:25:59 +02:00
|
|
|
|
unsigned NumIndex;
|
2017-09-19 01:12:05 +02:00
|
|
|
|
struct Project Prj;
|
2017-09-15 13:19:27 +02:00
|
|
|
|
|
|
|
|
|
/***** Get list of projects *****/
|
|
|
|
|
Prj_GetListProjects ();
|
|
|
|
|
|
|
|
|
|
/***** Compute variables related to pagination *****/
|
2017-09-17 16:58:09 +02:00
|
|
|
|
Pagination.NumItems = Gbl.Prjs.Num;
|
|
|
|
|
Pagination.CurrentPage = (int) Gbl.Prjs.CurrentPage;
|
2017-09-15 13:19:27 +02:00
|
|
|
|
Pag_CalculatePagination (&Pagination);
|
2017-09-17 16:58:09 +02:00
|
|
|
|
Gbl.Prjs.CurrentPage = (unsigned) Pagination.CurrentPage;
|
2017-09-15 13:19:27 +02:00
|
|
|
|
|
2019-10-26 02:19:42 +02:00
|
|
|
|
/***** Begin box *****/
|
2019-10-25 22:48:34 +02:00
|
|
|
|
Box_BoxBegin ("100%",Txt_Projects,Prj_PutIconsListProjects,
|
2017-09-17 16:58:09 +02:00
|
|
|
|
Hlp_ASSESSMENT_Projects,Box_NOT_CLOSABLE);
|
2017-09-15 13:19:27 +02:00
|
|
|
|
|
2017-10-10 01:26:45 +02:00
|
|
|
|
/***** Put forms to choice which projects to show *****/
|
2019-02-25 15:14:28 +01:00
|
|
|
|
/* 1st. row */
|
2019-03-26 11:53:21 +01:00
|
|
|
|
Set_StartSettingsHead ();
|
2017-10-10 12:37:09 +02:00
|
|
|
|
Prj_ShowFormToFilterByMy_All ();
|
2019-10-25 22:48:34 +02:00
|
|
|
|
Prj_ShowFormToFilterByAssign ();
|
2017-10-10 01:26:45 +02:00
|
|
|
|
switch (Gbl.Usrs.Me.Role.Logged)
|
|
|
|
|
{
|
|
|
|
|
case Rol_NET:
|
|
|
|
|
case Rol_TCH:
|
|
|
|
|
case Rol_SYS_ADM:
|
2017-10-10 12:37:09 +02:00
|
|
|
|
Prj_ShowFormToFilterByHidden ();
|
2017-10-10 01:26:45 +02:00
|
|
|
|
break;
|
|
|
|
|
default: // Students will see only visible projects
|
|
|
|
|
break;
|
|
|
|
|
}
|
2019-10-16 01:11:42 +02:00
|
|
|
|
Prj_ShowFormToFilterByWarning ();
|
2019-03-26 11:53:21 +01:00
|
|
|
|
Set_EndSettingsHead ();
|
2019-10-16 01:11:42 +02:00
|
|
|
|
|
2019-02-25 15:14:28 +01:00
|
|
|
|
/* 2nd. row */
|
2017-10-10 12:37:09 +02:00
|
|
|
|
Prj_ShowFormToFilterByDpt ();
|
2017-09-29 09:33:59 +02:00
|
|
|
|
|
2017-09-17 16:58:09 +02:00
|
|
|
|
if (Gbl.Prjs.Num)
|
2017-09-15 13:19:27 +02:00
|
|
|
|
{
|
2017-10-10 12:40:52 +02:00
|
|
|
|
/***** Write links to pages *****/
|
2019-12-11 00:13:09 +01:00
|
|
|
|
Pag_WriteLinksToPagesCentered (Pag_PROJECTS,
|
|
|
|
|
&Pagination,
|
|
|
|
|
0);
|
2017-10-10 12:40:52 +02:00
|
|
|
|
|
2017-09-19 01:12:05 +02:00
|
|
|
|
/***** Allocate memory for the project *****/
|
|
|
|
|
Prj_AllocMemProject (&Prj);
|
|
|
|
|
|
2017-09-15 13:19:27 +02:00
|
|
|
|
/***** Table head *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TABLE_BeginWideMarginPadding (2);
|
2017-10-10 18:25:59 +02:00
|
|
|
|
Prj_ShowProjectsHead (Prj_LIST_PROJECTS);
|
2017-09-15 13:19:27 +02:00
|
|
|
|
|
|
|
|
|
/***** Write all the projects *****/
|
2017-09-17 16:58:09 +02:00
|
|
|
|
for (NumPrj = Pagination.FirstItemVisible;
|
|
|
|
|
NumPrj <= Pagination.LastItemVisible;
|
|
|
|
|
NumPrj++)
|
2017-09-19 01:12:05 +02:00
|
|
|
|
{
|
2017-10-06 01:20:05 +02:00
|
|
|
|
/* Get project data */
|
2017-09-19 01:12:05 +02:00
|
|
|
|
Prj.PrjCod = Gbl.Prjs.LstPrjCods[NumPrj - 1];
|
2017-10-06 01:20:05 +02:00
|
|
|
|
Prj_GetDataOfProjectByCod (&Prj);
|
|
|
|
|
|
2017-10-10 18:25:59 +02:00
|
|
|
|
/* Number of index */
|
|
|
|
|
switch (Gbl.Prjs.SelectedOrder)
|
|
|
|
|
{
|
|
|
|
|
case Prj_ORDER_START_TIME:
|
|
|
|
|
case Prj_ORDER_END_TIME:
|
|
|
|
|
// NumPrj: 1, 2, 3 ==> NumIndex = 3, 2, 1
|
|
|
|
|
NumIndex = Gbl.Prjs.Num + 1 - NumPrj;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
// NumPrj: 1, 2, 3 ==> NumIndex = 1, 2, 3
|
|
|
|
|
NumIndex = NumPrj;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-06 01:20:05 +02:00
|
|
|
|
/* Show project */
|
2017-10-10 18:25:59 +02:00
|
|
|
|
Prj_ShowOneProject (NumIndex,&Prj,Prj_LIST_PROJECTS);
|
2017-09-19 01:12:05 +02:00
|
|
|
|
}
|
2017-09-15 13:19:27 +02:00
|
|
|
|
|
|
|
|
|
/***** End table *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TABLE_End ();
|
2017-09-19 01:12:05 +02:00
|
|
|
|
|
|
|
|
|
/***** Free memory of the project *****/
|
|
|
|
|
Prj_FreeMemProject (&Prj);
|
2017-10-10 12:40:52 +02:00
|
|
|
|
|
|
|
|
|
/***** Write again links to pages *****/
|
2019-12-11 00:13:09 +01:00
|
|
|
|
Pag_WriteLinksToPagesCentered (Pag_PROJECTS,
|
|
|
|
|
&Pagination,
|
|
|
|
|
0);
|
2017-09-15 13:19:27 +02:00
|
|
|
|
}
|
|
|
|
|
else // No projects created
|
2019-02-16 18:25:41 +01:00
|
|
|
|
Ale_ShowAlert (Ale_INFO,Txt_No_projects);
|
2017-09-15 13:19:27 +02:00
|
|
|
|
|
|
|
|
|
/***** Button to create a new project *****/
|
|
|
|
|
if (Prj_CheckIfICanCreateProjects ())
|
|
|
|
|
Prj_PutButtonToCreateNewPrj ();
|
|
|
|
|
|
|
|
|
|
/***** End box *****/
|
2019-10-25 22:48:34 +02:00
|
|
|
|
Box_BoxEnd ();
|
2017-09-15 13:19:27 +02:00
|
|
|
|
|
|
|
|
|
/***** Free list of projects *****/
|
|
|
|
|
Prj_FreeListProjects ();
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-29 09:33:59 +02:00
|
|
|
|
/*****************************************************************************/
|
2017-10-10 01:26:45 +02:00
|
|
|
|
/*** Show form to choice whether to show only my projects or all projects ****/
|
2017-09-29 09:33:59 +02:00
|
|
|
|
/*****************************************************************************/
|
2019-11-11 15:46:54 +01:00
|
|
|
|
|
|
|
|
|
static void Prj_ShowFormToFilterByMy_All (void)
|
|
|
|
|
{
|
|
|
|
|
struct Prj_Filter Filter;
|
|
|
|
|
Usr_Who_t Who;
|
2019-11-12 00:31:41 +01:00
|
|
|
|
unsigned Mask = 1 << Usr_WHO_ME |
|
|
|
|
|
1 << Usr_WHO_SELECTED |
|
|
|
|
|
1 << Usr_WHO_ALL;
|
2019-11-11 15:46:54 +01:00
|
|
|
|
|
|
|
|
|
Set_StartOneSettingSelector ();
|
2019-11-12 00:31:41 +01:00
|
|
|
|
for (Who = (Usr_Who_t) 1;
|
2019-11-11 15:46:54 +01:00
|
|
|
|
Who <= (Usr_Who_t) (Usr_NUM_WHO - 1);
|
|
|
|
|
Who++)
|
2019-11-12 00:31:41 +01:00
|
|
|
|
if (Mask & (1 << Who))
|
|
|
|
|
{
|
|
|
|
|
HTM_DIV_Begin ("class=\"%s\"",
|
|
|
|
|
(Gbl.Prjs.Filter.Who == Who) ? "PREF_ON" :
|
|
|
|
|
"PREF_OFF");
|
2019-11-14 09:39:21 +01:00
|
|
|
|
Frm_StartForm (Who == Usr_WHO_SELECTED ? ActReqUsrPrj :
|
|
|
|
|
ActSeePrj);
|
2019-11-12 00:31:41 +01:00
|
|
|
|
Filter.Who = Who;
|
|
|
|
|
Filter.Assign = Gbl.Prjs.Filter.Assign;
|
|
|
|
|
Filter.Hidden = Gbl.Prjs.Filter.Hidden;
|
|
|
|
|
Filter.Faulti = Gbl.Prjs.Filter.Faulti;
|
|
|
|
|
Filter.DptCod = Gbl.Prjs.Filter.DptCod;
|
|
|
|
|
Prj_PutParams (&Filter,
|
|
|
|
|
Gbl.Prjs.SelectedOrder,
|
|
|
|
|
Gbl.Prjs.CurrentPage,
|
|
|
|
|
-1L);
|
|
|
|
|
Usr_PutWhoIcon (Who);
|
|
|
|
|
Frm_EndForm ();
|
|
|
|
|
HTM_DIV_End ();
|
|
|
|
|
}
|
2019-11-11 15:46:54 +01:00
|
|
|
|
Set_EndOneSettingSelector ();
|
|
|
|
|
}
|
2017-09-29 09:33:59 +02:00
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2019-10-25 22:48:34 +02:00
|
|
|
|
/*********** Show form to select assigned / non-assigned projects ************/
|
2017-10-10 01:26:45 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2019-10-25 22:48:34 +02:00
|
|
|
|
static void Prj_ShowFormToFilterByAssign (void)
|
2017-10-10 01:26:45 +02:00
|
|
|
|
{
|
2019-10-25 22:48:34 +02:00
|
|
|
|
extern const char *Txt_PROJECT_ASSIGNED_NONASSIGNED_PLURAL[Prj_NUM_ASSIGNED_NONASSIG];
|
2017-10-10 12:52:02 +02:00
|
|
|
|
struct Prj_Filter Filter;
|
2019-10-25 22:48:34 +02:00
|
|
|
|
Prj_AssignedNonassig_t Assign;
|
2017-10-10 01:26:45 +02:00
|
|
|
|
|
2019-03-26 11:53:21 +01:00
|
|
|
|
Set_StartOneSettingSelector ();
|
2019-12-15 20:02:34 +01:00
|
|
|
|
for (Assign = (Prj_AssignedNonassig_t) 0;
|
2019-10-25 22:48:34 +02:00
|
|
|
|
Assign <= (Prj_AssignedNonassig_t) (Prj_NUM_ASSIGNED_NONASSIG - 1);
|
|
|
|
|
Assign++)
|
2017-10-10 01:26:45 +02:00
|
|
|
|
{
|
2019-10-24 00:04:40 +02:00
|
|
|
|
HTM_DIV_Begin ("class=\"%s\"",
|
2019-10-25 22:48:34 +02:00
|
|
|
|
(Gbl.Prjs.Filter.Assign & (1 << Assign)) ? "PREF_ON" :
|
2019-10-24 00:04:40 +02:00
|
|
|
|
"PREF_OFF");
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_StartForm (ActSeePrj);
|
2019-11-11 15:46:54 +01:00
|
|
|
|
Filter.Who = Gbl.Prjs.Filter.Who;
|
2019-10-25 22:48:34 +02:00
|
|
|
|
Filter.Assign = Gbl.Prjs.Filter.Assign ^ (1 << Assign); // Toggle
|
2019-10-25 01:15:11 +02:00
|
|
|
|
Filter.Hidden = Gbl.Prjs.Filter.Hidden;
|
2019-10-16 01:11:42 +02:00
|
|
|
|
Filter.Faulti = Gbl.Prjs.Filter.Faulti;
|
2017-10-10 12:52:02 +02:00
|
|
|
|
Filter.DptCod = Gbl.Prjs.Filter.DptCod;
|
|
|
|
|
Prj_PutParams (&Filter,
|
2017-10-10 01:26:45 +02:00
|
|
|
|
Gbl.Prjs.SelectedOrder,
|
|
|
|
|
Gbl.Prjs.CurrentPage,
|
|
|
|
|
-1L);
|
2019-10-25 22:48:34 +02:00
|
|
|
|
Ico_PutSettingIconLink (AssignedNonassigImage[Assign],
|
|
|
|
|
Txt_PROJECT_ASSIGNED_NONASSIGNED_PLURAL[Assign]);
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_EndForm ();
|
2019-10-23 20:07:56 +02:00
|
|
|
|
HTM_DIV_End ();
|
2017-10-10 01:26:45 +02:00
|
|
|
|
}
|
2019-03-26 11:53:21 +01:00
|
|
|
|
Set_EndOneSettingSelector ();
|
2017-10-10 01:26:45 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************* Show form to select hidden / visible projects *****************/
|
2017-09-29 09:33:59 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2017-10-10 12:37:09 +02:00
|
|
|
|
static void Prj_ShowFormToFilterByHidden (void)
|
2017-09-29 09:33:59 +02:00
|
|
|
|
{
|
2017-10-10 01:26:45 +02:00
|
|
|
|
extern const char *Txt_PROJECT_HIDDEN_VISIBL_PROJECTS[Prj_NUM_HIDDEN_VISIBL];
|
2017-10-10 12:52:02 +02:00
|
|
|
|
struct Prj_Filter Filter;
|
2017-10-10 01:26:45 +02:00
|
|
|
|
Prj_HiddenVisibl_t HidVis;
|
2019-02-21 21:12:04 +01:00
|
|
|
|
static const char *HiddenVisiblIcon[Prj_NUM_HIDDEN_VISIBL] =
|
2017-10-10 01:26:45 +02:00
|
|
|
|
{
|
2019-11-21 01:27:17 +01:00
|
|
|
|
[Prj_HIDDEN] = "eye-slash.svg",
|
|
|
|
|
[Prj_VISIBL] = "eye.svg",
|
2017-10-10 01:26:45 +02:00
|
|
|
|
};
|
2017-09-29 09:33:59 +02:00
|
|
|
|
|
2019-03-26 11:53:21 +01:00
|
|
|
|
Set_StartOneSettingSelector ();
|
2019-12-15 20:02:34 +01:00
|
|
|
|
for (HidVis = (Prj_HiddenVisibl_t) 0;
|
2017-10-10 01:26:45 +02:00
|
|
|
|
HidVis <= (Prj_HiddenVisibl_t) (Prj_NUM_HIDDEN_VISIBL - 1);
|
|
|
|
|
HidVis++)
|
2017-09-29 09:33:59 +02:00
|
|
|
|
{
|
2019-10-24 00:04:40 +02:00
|
|
|
|
HTM_DIV_Begin ("class=\"%s\"",
|
2019-10-25 01:15:11 +02:00
|
|
|
|
(Gbl.Prjs.Filter.Hidden & (1 << HidVis)) ? "PREF_ON" :
|
2019-10-24 00:04:40 +02:00
|
|
|
|
"PREF_OFF");
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_StartForm (ActSeePrj);
|
2019-11-11 15:46:54 +01:00
|
|
|
|
Filter.Who = Gbl.Prjs.Filter.Who;
|
2019-10-25 01:15:11 +02:00
|
|
|
|
Filter.Assign = Gbl.Prjs.Filter.Assign;
|
|
|
|
|
Filter.Hidden = Gbl.Prjs.Filter.Hidden ^ (1 << HidVis); // Toggle
|
2019-10-16 01:11:42 +02:00
|
|
|
|
Filter.Faulti = Gbl.Prjs.Filter.Faulti;
|
2017-10-10 12:52:02 +02:00
|
|
|
|
Filter.DptCod = Gbl.Prjs.Filter.DptCod;
|
|
|
|
|
Prj_PutParams (&Filter,
|
2017-10-10 01:26:45 +02:00
|
|
|
|
Gbl.Prjs.SelectedOrder,
|
|
|
|
|
Gbl.Prjs.CurrentPage,
|
|
|
|
|
-1L);
|
2019-03-26 11:53:21 +01:00
|
|
|
|
Ico_PutSettingIconLink (HiddenVisiblIcon[HidVis],
|
2019-04-20 13:01:55 +02:00
|
|
|
|
Txt_PROJECT_HIDDEN_VISIBL_PROJECTS[HidVis]);
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_EndForm ();
|
2019-10-23 20:07:56 +02:00
|
|
|
|
HTM_DIV_End ();
|
2017-09-29 09:33:59 +02:00
|
|
|
|
}
|
2019-03-26 11:53:21 +01:00
|
|
|
|
Set_EndOneSettingSelector ();
|
2017-09-29 09:33:59 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-10-16 01:11:42 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************** Show form to select faulty/faultless projects ****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Prj_ShowFormToFilterByWarning (void)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_PROJECT_FAULTY_FAULTLESS_PROJECTS[Prj_NUM_FAULTINESS];
|
|
|
|
|
struct Prj_Filter Filter;
|
|
|
|
|
Prj_Faultiness_t Faultiness;
|
|
|
|
|
static const char *FaultinessIcon[Prj_NUM_FAULTINESS] =
|
|
|
|
|
{
|
2019-11-21 01:27:17 +01:00
|
|
|
|
[Prj_FAULTY ] = "exclamation-triangle.svg",
|
|
|
|
|
[Prj_FAULTLESS] = "check-circle.svg",
|
2019-10-16 01:11:42 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Set_StartOneSettingSelector ();
|
2019-12-15 20:02:34 +01:00
|
|
|
|
for (Faultiness = (Prj_Faultiness_t) 0;
|
2019-10-16 01:11:42 +02:00
|
|
|
|
Faultiness <= (Prj_Faultiness_t) (Prj_NUM_FAULTINESS - 1);
|
|
|
|
|
Faultiness++)
|
|
|
|
|
{
|
2019-10-24 00:04:40 +02:00
|
|
|
|
HTM_DIV_Begin ("class=\"%s\"",
|
|
|
|
|
(Gbl.Prjs.Filter.Faulti & (1 << Faultiness)) ? "PREF_ON" :
|
|
|
|
|
"PREF_OFF");
|
2019-10-16 01:11:42 +02:00
|
|
|
|
Frm_StartForm (ActSeePrj);
|
2019-11-11 15:46:54 +01:00
|
|
|
|
Filter.Who = Gbl.Prjs.Filter.Who;
|
2019-10-25 01:15:11 +02:00
|
|
|
|
Filter.Assign = Gbl.Prjs.Filter.Assign;
|
|
|
|
|
Filter.Hidden = Gbl.Prjs.Filter.Hidden;
|
2019-10-16 01:11:42 +02:00
|
|
|
|
Filter.Faulti = Gbl.Prjs.Filter.Faulti ^ (1 << Faultiness); // Toggle
|
|
|
|
|
Filter.DptCod = Gbl.Prjs.Filter.DptCod;
|
|
|
|
|
Prj_PutParams (&Filter,
|
|
|
|
|
Gbl.Prjs.SelectedOrder,
|
|
|
|
|
Gbl.Prjs.CurrentPage,
|
|
|
|
|
-1L);
|
|
|
|
|
Ico_PutSettingIconLink (FaultinessIcon[Faultiness],
|
|
|
|
|
Txt_PROJECT_FAULTY_FAULTLESS_PROJECTS[Faultiness]);
|
|
|
|
|
Frm_EndForm ();
|
2019-10-23 20:07:56 +02:00
|
|
|
|
HTM_DIV_End ();
|
2019-10-16 01:11:42 +02:00
|
|
|
|
}
|
|
|
|
|
Set_EndOneSettingSelector ();
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-10 12:37:09 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*************** Show form to filter projects by department ******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Prj_ShowFormToFilterByDpt (void)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Any_department;
|
2017-10-10 12:52:02 +02:00
|
|
|
|
struct Prj_Filter Filter;
|
2017-10-10 12:37:09 +02:00
|
|
|
|
|
2019-10-20 22:00:28 +02:00
|
|
|
|
/***** Begin form *****/
|
2019-10-24 23:03:19 +02:00
|
|
|
|
HTM_DIV_Begin (NULL);
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_StartForm (ActSeePrj);
|
2019-11-11 15:46:54 +01:00
|
|
|
|
Filter.Who = Gbl.Prjs.Filter.Who;
|
2019-10-25 01:15:11 +02:00
|
|
|
|
Filter.Assign = Gbl.Prjs.Filter.Assign;
|
|
|
|
|
Filter.Hidden = Gbl.Prjs.Filter.Hidden;
|
2019-10-16 01:11:42 +02:00
|
|
|
|
Filter.Faulti = Gbl.Prjs.Filter.Faulti;
|
2017-10-10 12:52:02 +02:00
|
|
|
|
Filter.DptCod = Prj_FILTER_DPT_DEFAULT; // Do not put department parameter here
|
|
|
|
|
Prj_PutParams (&Filter,
|
2017-10-10 12:37:09 +02:00
|
|
|
|
Gbl.Prjs.SelectedOrder,
|
|
|
|
|
Gbl.Prjs.CurrentPage,
|
|
|
|
|
-1L);
|
|
|
|
|
|
|
|
|
|
/***** Write selector with departments *****/
|
2019-04-03 20:57:04 +02:00
|
|
|
|
Dpt_WriteSelectorDepartment (Gbl.Hierarchy.Ins.InsCod, // Departments in current insitution
|
2017-10-10 12:37:09 +02:00
|
|
|
|
Gbl.Prjs.Filter.DptCod, // Selected department
|
2019-11-27 00:27:42 +01:00
|
|
|
|
"TITLE_DESCRIPTION_WIDTH", // Selector class
|
2017-10-10 12:37:09 +02:00
|
|
|
|
-1L, // First option
|
|
|
|
|
Txt_Any_department, // Text when no department selected
|
|
|
|
|
true); // Submit on change
|
|
|
|
|
|
|
|
|
|
/***** End form *****/
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_EndForm ();
|
2019-10-23 20:07:56 +02:00
|
|
|
|
HTM_DIV_End ();
|
2017-10-10 12:37:09 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-09-29 15:05:23 +02:00
|
|
|
|
/*****************************************************************************/
|
2017-10-10 01:26:45 +02:00
|
|
|
|
/********************** Put parameters used in projects **********************/
|
2017-09-29 15:05:23 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2017-10-10 01:26:45 +02:00
|
|
|
|
static void Prj_PutCurrentParams (void)
|
2017-09-29 15:05:23 +02:00
|
|
|
|
{
|
2017-10-10 12:52:02 +02:00
|
|
|
|
Prj_PutParams (&Gbl.Prjs.Filter,
|
2017-10-10 01:26:45 +02:00
|
|
|
|
Gbl.Prjs.SelectedOrder,
|
|
|
|
|
Gbl.Prjs.CurrentPage,
|
|
|
|
|
Gbl.Prjs.PrjCod);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* The following function is called
|
|
|
|
|
when one or more parameters must be passed explicitely.
|
|
|
|
|
Each parameter is passed only if its value is distinct to default. */
|
|
|
|
|
|
2017-10-10 12:52:02 +02:00
|
|
|
|
void Prj_PutParams (struct Prj_Filter *Filter,
|
2017-10-10 01:26:45 +02:00
|
|
|
|
Prj_Order_t Order,
|
|
|
|
|
unsigned NumPage,
|
|
|
|
|
long PrjCod)
|
|
|
|
|
{
|
2017-10-10 12:37:09 +02:00
|
|
|
|
/***** Put filter parameters (which projects to show) *****/
|
2019-11-12 00:31:41 +01:00
|
|
|
|
if (Filter->Who != Prj_FILTER_WHO_DEFAULT)
|
|
|
|
|
Usr_PutHiddenParamWho (Filter->Who);
|
2017-10-10 01:26:45 +02:00
|
|
|
|
|
2019-10-25 01:15:11 +02:00
|
|
|
|
if (Filter->Assign != ((unsigned) Prj_FILTER_ASSIGNED_DEFAULT |
|
|
|
|
|
(unsigned) Prj_FILTER_NONASSIG_DEFAULT))
|
|
|
|
|
Prj_PutHiddenParamAssign (Filter->Assign);
|
2017-10-10 01:26:45 +02:00
|
|
|
|
|
2019-10-25 01:15:11 +02:00
|
|
|
|
if (Filter->Hidden != ((unsigned) Prj_FILTER_HIDDEN_DEFAULT |
|
2017-10-10 12:52:02 +02:00
|
|
|
|
(unsigned) Prj_FILTER_VISIBL_DEFAULT))
|
2019-10-25 01:15:11 +02:00
|
|
|
|
Prj_PutHiddenParamHidden (Filter->Hidden);
|
2017-10-10 01:26:45 +02:00
|
|
|
|
|
2019-10-16 01:11:42 +02:00
|
|
|
|
if (Filter->Faulti != ((unsigned) Prj_FILTER_FAULTY_DEFAULT |
|
|
|
|
|
(unsigned) Prj_FILTER_FAULTLESS_DEFAULT))
|
|
|
|
|
Prj_PutHiddenParamFaulti (Filter->Faulti);
|
|
|
|
|
|
2017-10-10 12:52:02 +02:00
|
|
|
|
if (Filter->DptCod != Prj_FILTER_DPT_DEFAULT)
|
|
|
|
|
Prj_PutHiddenParamDptCod (Filter->DptCod);
|
2017-10-10 12:37:09 +02:00
|
|
|
|
|
|
|
|
|
/***** Put order field *****/
|
2017-10-10 01:26:45 +02:00
|
|
|
|
if (Order != Prj_ORDER_DEFAULT)
|
2019-11-03 13:19:32 +01:00
|
|
|
|
Par_PutHiddenParamUnsigned (NULL,"Order",(unsigned) Order);
|
2017-10-10 01:26:45 +02:00
|
|
|
|
|
2017-10-10 12:37:09 +02:00
|
|
|
|
/***** Put number of page *****/
|
2017-10-10 01:26:45 +02:00
|
|
|
|
if (NumPage > 1)
|
|
|
|
|
Pag_PutHiddenParamPagNum (Pag_PROJECTS,NumPage);
|
|
|
|
|
|
2017-10-10 12:37:09 +02:00
|
|
|
|
/***** Put selected project code *****/
|
2017-10-10 01:26:45 +02:00
|
|
|
|
if (PrjCod > 0)
|
|
|
|
|
Prj_PutParamPrjCod (PrjCod);
|
|
|
|
|
|
2017-10-10 12:37:09 +02:00
|
|
|
|
/***** Put another user's code *****/
|
2017-10-10 01:26:45 +02:00
|
|
|
|
if (Gbl.Usrs.Other.UsrDat.UsrCod > 0)
|
|
|
|
|
Usr_PutParamOtherUsrCodEncrypted ();
|
2019-11-14 02:29:18 +01:00
|
|
|
|
|
|
|
|
|
/***** Put selected users' codes *****/
|
|
|
|
|
if (Filter->Who == Usr_WHO_SELECTED)
|
2019-11-15 03:34:48 +01:00
|
|
|
|
Usr_PutHiddenParSelectedUsrsCods (&Gbl.Usrs.Selected);
|
2017-10-10 01:26:45 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*********************** Put hidden params for projects **********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2019-10-25 01:15:11 +02:00
|
|
|
|
static void Prj_PutHiddenParamAssign (unsigned Assign)
|
2017-10-10 01:26:45 +02:00
|
|
|
|
{
|
2019-11-03 13:19:32 +01:00
|
|
|
|
Par_PutHiddenParamUnsigned (NULL,Prj_PARAM_PRE_NON_NAME,Assign);
|
2017-10-10 01:26:45 +02:00
|
|
|
|
}
|
2017-09-29 15:05:23 +02:00
|
|
|
|
|
2019-10-25 01:15:11 +02:00
|
|
|
|
static void Prj_PutHiddenParamHidden (unsigned Hidden)
|
2017-10-10 01:26:45 +02:00
|
|
|
|
{
|
2019-11-03 13:19:32 +01:00
|
|
|
|
Par_PutHiddenParamUnsigned (NULL,Prj_PARAM_HID_VIS_NAME,Hidden);
|
2017-10-10 12:37:09 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-10-16 01:11:42 +02:00
|
|
|
|
static void Prj_PutHiddenParamFaulti (unsigned Faulti)
|
|
|
|
|
{
|
2019-11-03 13:19:32 +01:00
|
|
|
|
Par_PutHiddenParamUnsigned (NULL,Prj_PARAM_FAULTIN_NAME,Faulti);
|
2019-10-16 01:11:42 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-10-10 12:37:09 +02:00
|
|
|
|
static void Prj_PutHiddenParamDptCod (long DptCod)
|
|
|
|
|
{
|
2019-11-03 13:19:32 +01:00
|
|
|
|
Par_PutHiddenParamUnsigned (NULL,Dpt_PARAM_DPT_COD_NAME,DptCod);
|
2017-09-29 15:05:23 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2017-10-10 01:26:45 +02:00
|
|
|
|
/*********************** Get hidden params for projects **********************/
|
2017-09-29 15:05:23 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2017-10-10 01:26:45 +02:00
|
|
|
|
static void Prj_GetHiddenParamPreNon (void)
|
|
|
|
|
{
|
2019-10-25 01:15:11 +02:00
|
|
|
|
Gbl.Prjs.Filter.Assign = (unsigned) Par_GetParToUnsignedLong (Prj_PARAM_PRE_NON_NAME,
|
2017-10-10 10:55:09 +02:00
|
|
|
|
0,
|
2019-10-25 01:15:11 +02:00
|
|
|
|
(1 << Prj_ASSIGNED) |
|
|
|
|
|
(1 << Prj_NONASSIG),
|
|
|
|
|
(unsigned) Prj_FILTER_ASSIGNED_DEFAULT |
|
|
|
|
|
(unsigned) Prj_FILTER_NONASSIG_DEFAULT);
|
2017-10-10 01:26:45 +02:00
|
|
|
|
}
|
2017-09-29 15:05:23 +02:00
|
|
|
|
|
2017-10-10 01:26:45 +02:00
|
|
|
|
static void Prj_GetHiddenParamHidVis (void)
|
|
|
|
|
{
|
|
|
|
|
switch (Gbl.Usrs.Me.Role.Logged)
|
2017-09-29 15:05:23 +02:00
|
|
|
|
{
|
2017-10-10 01:26:45 +02:00
|
|
|
|
case Rol_STD: // Students can view only visible projects
|
2019-10-25 01:15:11 +02:00
|
|
|
|
Gbl.Prjs.Filter.Hidden = (1 << Prj_VISIBL); // Only visible projects
|
2017-10-10 01:26:45 +02:00
|
|
|
|
break;
|
|
|
|
|
case Rol_NET:
|
|
|
|
|
case Rol_TCH:
|
|
|
|
|
case Rol_SYS_ADM:
|
2019-10-25 01:15:11 +02:00
|
|
|
|
Gbl.Prjs.Filter.Hidden = (unsigned) Par_GetParToUnsignedLong (Prj_PARAM_HID_VIS_NAME,
|
2017-10-10 10:55:09 +02:00
|
|
|
|
0,
|
|
|
|
|
(1 << Prj_HIDDEN) |
|
|
|
|
|
(1 << Prj_VISIBL),
|
2017-10-10 12:37:09 +02:00
|
|
|
|
(unsigned) Prj_FILTER_HIDDEN_DEFAULT |
|
|
|
|
|
(unsigned) Prj_FILTER_VISIBL_DEFAULT);
|
2017-10-10 01:26:45 +02:00
|
|
|
|
break;
|
|
|
|
|
default:
|
2019-09-28 15:03:22 +02:00
|
|
|
|
Rol_WrongRoleExit ();
|
2017-10-10 01:26:45 +02:00
|
|
|
|
break;
|
2017-09-29 15:05:23 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-16 01:11:42 +02:00
|
|
|
|
static void Prj_GetHiddenParamFaulti (void)
|
|
|
|
|
{
|
|
|
|
|
Gbl.Prjs.Filter.Faulti = (unsigned) Par_GetParToUnsignedLong (Prj_PARAM_FAULTIN_NAME,
|
|
|
|
|
0,
|
|
|
|
|
(1 << Prj_FAULTY) |
|
|
|
|
|
(1 << Prj_FAULTLESS),
|
|
|
|
|
(unsigned) Prj_FILTER_FAULTY_DEFAULT |
|
|
|
|
|
(unsigned) Prj_FILTER_FAULTLESS_DEFAULT);
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-10 12:37:09 +02:00
|
|
|
|
static void Prj_GetHiddenParamDptCod (void)
|
|
|
|
|
{
|
|
|
|
|
Gbl.Prjs.Filter.DptCod = Par_GetParToLong (Dpt_PARAM_DPT_COD_NAME);
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-10 01:26:45 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************** Get generic parameters to list projects *******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Prj_GetParams (void)
|
|
|
|
|
{
|
2017-10-10 12:37:09 +02:00
|
|
|
|
/***** Get filter (which projects to show) *****/
|
2019-11-12 00:31:41 +01:00
|
|
|
|
Prj_GetParamWho ();
|
2017-10-10 01:26:45 +02:00
|
|
|
|
Prj_GetHiddenParamPreNon ();
|
|
|
|
|
Prj_GetHiddenParamHidVis ();
|
2019-10-16 01:11:42 +02:00
|
|
|
|
Prj_GetHiddenParamFaulti ();
|
2017-10-10 12:37:09 +02:00
|
|
|
|
Prj_GetHiddenParamDptCod ();
|
2017-10-10 01:26:45 +02:00
|
|
|
|
|
|
|
|
|
/***** Get order and page *****/
|
|
|
|
|
Prj_GetParamPrjOrder ();
|
|
|
|
|
Gbl.Prjs.CurrentPage = Pag_GetParamPagNum (Pag_PROJECTS);
|
2019-11-15 03:34:48 +01:00
|
|
|
|
|
|
|
|
|
/***** Get selected users *****/
|
|
|
|
|
if (Gbl.Prjs.Filter.Who == Usr_WHO_SELECTED)
|
|
|
|
|
Usr_GetListsSelectedEncryptedUsrsCods (&Gbl.Usrs.Selected);
|
2017-10-10 01:26:45 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-11-12 00:31:41 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************* Get parameter with whose users' projects to view **************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Prj_GetParamWho (void)
|
|
|
|
|
{
|
|
|
|
|
/***** Get which users I want to see *****/
|
|
|
|
|
Gbl.Prjs.Filter.Who = Usr_GetHiddenParamWho ();
|
|
|
|
|
|
|
|
|
|
/***** If parameter Who is unknown, set it to default *****/
|
|
|
|
|
if (Gbl.Prjs.Filter.Who == Usr_WHO_UNKNOWN)
|
|
|
|
|
Gbl.Prjs.Filter.Who = Prj_FILTER_WHO_DEFAULT;
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-15 13:19:27 +02:00
|
|
|
|
/*****************************************************************************/
|
2017-09-17 16:58:09 +02:00
|
|
|
|
/******************* Write header with fields of a project *******************/
|
2017-09-15 13:19:27 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2017-10-10 18:25:59 +02:00
|
|
|
|
static void Prj_ShowProjectsHead (Prj_ProjectView_t ProjectView)
|
2017-09-15 13:19:27 +02:00
|
|
|
|
{
|
2017-10-10 18:25:59 +02:00
|
|
|
|
extern const char *Txt_No_INDEX;
|
2017-09-23 21:15:17 +02:00
|
|
|
|
extern const char *Txt_PROJECT_ORDER_HELP[Prj_NUM_ORDERS];
|
|
|
|
|
extern const char *Txt_PROJECT_ORDER[Prj_NUM_ORDERS];
|
|
|
|
|
Prj_Order_t Order;
|
2017-09-15 13:19:27 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_Begin (NULL);
|
2017-10-10 18:25:59 +02:00
|
|
|
|
|
|
|
|
|
/***** Column for number of project *****/
|
|
|
|
|
switch (ProjectView)
|
|
|
|
|
{
|
|
|
|
|
case Prj_LIST_PROJECTS:
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TH (1,1,"CM",Txt_No_INDEX);
|
2017-10-10 18:25:59 +02:00
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Column for contextual icons *****/
|
|
|
|
|
switch (ProjectView)
|
|
|
|
|
{
|
|
|
|
|
case Prj_LIST_PROJECTS:
|
|
|
|
|
case Prj_FILE_BROWSER_PROJECT:
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TH (1,1,"CONTEXT_COL",NULL);
|
2017-10-10 18:25:59 +02:00
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Rest of columns *****/
|
2019-12-15 20:02:34 +01:00
|
|
|
|
for (Order = (Prj_Order_t) 0;
|
2017-09-23 21:15:17 +02:00
|
|
|
|
Order <= (Prj_Order_t) (Prj_NUM_ORDERS - 1);
|
2017-09-15 13:19:27 +02:00
|
|
|
|
Order++)
|
|
|
|
|
{
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TH_Begin (1,1,"CM");
|
2017-09-15 13:19:27 +02:00
|
|
|
|
|
2017-10-10 18:25:59 +02:00
|
|
|
|
switch (ProjectView)
|
2017-09-15 13:19:27 +02:00
|
|
|
|
{
|
2017-10-10 18:25:59 +02:00
|
|
|
|
case Prj_LIST_PROJECTS:
|
|
|
|
|
case Prj_FILE_BROWSER_PROJECT:
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_StartForm (ActSeePrj);
|
2017-10-10 18:25:59 +02:00
|
|
|
|
Prj_PutParams (&Gbl.Prjs.Filter,
|
|
|
|
|
Order,
|
|
|
|
|
Gbl.Prjs.CurrentPage,
|
|
|
|
|
-1L);
|
2019-11-20 10:17:42 +01:00
|
|
|
|
HTM_BUTTON_SUBMIT_Begin (Txt_PROJECT_ORDER_HELP[Order],"BT_LINK TIT_TBL",NULL);
|
2017-10-10 18:25:59 +02:00
|
|
|
|
if (Order == Gbl.Prjs.SelectedOrder)
|
2019-11-10 16:41:47 +01:00
|
|
|
|
HTM_U_Begin ();
|
2019-11-10 12:36:37 +01:00
|
|
|
|
HTM_Txt (Txt_PROJECT_ORDER[Order]);
|
2017-10-10 18:25:59 +02:00
|
|
|
|
if (Order == Gbl.Prjs.SelectedOrder)
|
2019-11-10 16:41:47 +01:00
|
|
|
|
HTM_U_End ();
|
2019-11-18 20:12:10 +01:00
|
|
|
|
HTM_BUTTON_End ();
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_EndForm ();
|
2017-10-10 18:25:59 +02:00
|
|
|
|
break;
|
|
|
|
|
default:
|
2019-11-10 12:36:37 +01:00
|
|
|
|
HTM_Txt (Txt_PROJECT_ORDER[Order]);
|
2017-10-10 18:25:59 +02:00
|
|
|
|
break;
|
2017-09-15 13:19:27 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TH_End ();
|
2017-09-15 13:19:27 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-24 13:35:19 +02:00
|
|
|
|
static void Prj_ShowTableAllProjectsHead (void)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_PROJECT_ORDER[Prj_NUM_ORDERS];
|
2019-10-25 01:15:11 +02:00
|
|
|
|
extern const char *Txt_Assigned_QUESTION;
|
2017-10-02 02:19:14 +02:00
|
|
|
|
extern const char *Txt_Number_of_students;
|
2017-10-02 01:16:10 +02:00
|
|
|
|
extern const char *Txt_PROJECT_ROLES_PLURAL_Abc[Prj_NUM_ROLES_IN_PROJECT];
|
2017-10-02 19:34:31 +02:00
|
|
|
|
extern const char *Txt_Proposal;
|
2017-09-24 13:35:19 +02:00
|
|
|
|
extern const char *Txt_Description;
|
|
|
|
|
extern const char *Txt_Required_knowledge;
|
|
|
|
|
extern const char *Txt_Required_materials;
|
2017-09-24 18:51:56 +02:00
|
|
|
|
extern const char *Txt_URL;
|
2017-09-24 13:35:19 +02:00
|
|
|
|
Prj_Order_t Order;
|
2017-10-01 00:48:36 +02:00
|
|
|
|
unsigned NumRoleToShow;
|
2017-09-24 13:35:19 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_Begin (NULL);
|
2017-10-01 18:44:50 +02:00
|
|
|
|
|
2019-12-15 20:02:34 +01:00
|
|
|
|
for (Order = (Prj_Order_t) 0;
|
2017-09-24 13:35:19 +02:00
|
|
|
|
Order <= (Prj_Order_t) (Prj_NUM_ORDERS - 1);
|
|
|
|
|
Order++)
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TH (1,1,"LT DAT_N",Txt_PROJECT_ORDER[Order]);
|
2019-10-25 01:15:11 +02:00
|
|
|
|
HTM_TH (1,1,"LT DAT_N",Txt_Assigned_QUESTION);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TH (1,1,"LT DAT_N",Txt_Number_of_students);
|
2017-10-01 00:48:36 +02:00
|
|
|
|
for (NumRoleToShow = 0;
|
|
|
|
|
NumRoleToShow < Brw_NUM_ROLES_TO_SHOW;
|
|
|
|
|
NumRoleToShow++)
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TH (1,1,"LT DAT_N",Txt_PROJECT_ROLES_PLURAL_Abc[Prj_RolesToShow[NumRoleToShow]]);
|
|
|
|
|
HTM_TH (1,1,"LT DAT_N",Txt_Proposal);
|
|
|
|
|
HTM_TH (1,1,"LT DAT_N",Txt_Description);
|
|
|
|
|
HTM_TH (1,1,"LT DAT_N",Txt_Required_knowledge);
|
|
|
|
|
HTM_TH (1,1,"LT DAT_N",Txt_Required_materials);
|
|
|
|
|
HTM_TH (1,1,"LT DAT_N",Txt_URL);
|
2017-10-01 18:44:50 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_End ();
|
2017-09-24 13:35:19 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-09-15 13:19:27 +02:00
|
|
|
|
/*****************************************************************************/
|
2017-09-17 16:58:09 +02:00
|
|
|
|
/********************** Check if I can create projects ***********************/
|
2017-09-15 13:19:27 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static bool Prj_CheckIfICanCreateProjects (void)
|
|
|
|
|
{
|
2017-09-24 18:51:56 +02:00
|
|
|
|
static const bool ICanCreateProjects[Rol_NUM_ROLES] =
|
|
|
|
|
{
|
2019-11-21 01:27:17 +01:00
|
|
|
|
[Rol_UNK ] = false,
|
|
|
|
|
[Rol_GST ] = false,
|
|
|
|
|
[Rol_USR ] = false,
|
|
|
|
|
[Rol_STD ] = false,
|
|
|
|
|
[Rol_NET ] = true,
|
|
|
|
|
[Rol_TCH ] = true,
|
|
|
|
|
[Rol_DEG_ADM] = true,
|
|
|
|
|
[Rol_CTR_ADM] = true,
|
|
|
|
|
[Rol_INS_ADM] = true,
|
|
|
|
|
[Rol_SYS_ADM] = true,
|
2017-09-24 18:51:56 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return ICanCreateProjects[Gbl.Usrs.Me.Role.Logged];
|
2017-09-15 13:19:27 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2017-09-17 16:58:09 +02:00
|
|
|
|
/***************** Put contextual icons in list of projects ******************/
|
2017-09-15 13:19:27 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Prj_PutIconsListProjects (void)
|
|
|
|
|
{
|
2019-10-25 22:48:34 +02:00
|
|
|
|
bool ICanConfigAllProjects = Prj_CheckIfICanConfigAllProjects ();
|
|
|
|
|
|
2017-09-15 13:19:27 +02:00
|
|
|
|
/***** Put icon to create a new project *****/
|
|
|
|
|
if (Prj_CheckIfICanCreateProjects ())
|
|
|
|
|
Prj_PutIconToCreateNewPrj ();
|
|
|
|
|
|
2019-04-18 14:06:00 +02:00
|
|
|
|
if (Gbl.Prjs.Num)
|
|
|
|
|
{
|
|
|
|
|
/***** Put icon to show all data in a table *****/
|
|
|
|
|
Prj_PutIconToShowAllData ();
|
|
|
|
|
|
2019-10-25 22:48:34 +02:00
|
|
|
|
if (ICanConfigAllProjects)
|
|
|
|
|
/****** Put icons to request locking/unlocking edition
|
|
|
|
|
of all selected projects *******/
|
2019-04-18 14:06:00 +02:00
|
|
|
|
Prj_PutIconsToLockUnlockAllProjects ();
|
|
|
|
|
}
|
2017-09-23 21:36:08 +02:00
|
|
|
|
|
2019-10-25 22:48:34 +02:00
|
|
|
|
/***** Put form to go to configuration of projects *****/
|
|
|
|
|
if (ICanConfigAllProjects)
|
|
|
|
|
Ico_PutContextualIconToConfigure (ActCfgPrj,NULL);
|
|
|
|
|
|
2017-09-15 13:19:27 +02:00
|
|
|
|
/***** Put icon to show a figure *****/
|
2019-02-12 14:46:14 +01:00
|
|
|
|
Gbl.Figures.FigureType = Fig_PROJECTS;
|
|
|
|
|
Fig_PutIconToShowFigure ();
|
2017-09-15 13:19:27 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2017-09-17 16:58:09 +02:00
|
|
|
|
/********************* Put icon to create a new project **********************/
|
2017-09-15 13:19:27 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Prj_PutIconToCreateNewPrj (void)
|
|
|
|
|
{
|
2017-09-17 16:58:09 +02:00
|
|
|
|
extern const char *Txt_New_project;
|
2017-09-15 13:19:27 +02:00
|
|
|
|
|
|
|
|
|
/***** Put form to create a new project *****/
|
2017-10-10 01:26:45 +02:00
|
|
|
|
Gbl.Prjs.PrjCod = -1L;
|
2019-01-10 15:26:33 +01:00
|
|
|
|
Ico_PutContextualIconToAdd (ActFrmNewPrj,NULL,Prj_PutCurrentParams,
|
|
|
|
|
Txt_New_project);
|
2017-09-15 13:19:27 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2017-09-17 16:58:09 +02:00
|
|
|
|
/******************** Put button to create a new project *********************/
|
2017-09-15 13:19:27 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Prj_PutButtonToCreateNewPrj (void)
|
|
|
|
|
{
|
2017-09-17 16:58:09 +02:00
|
|
|
|
extern const char *Txt_New_project;
|
2017-09-15 13:19:27 +02:00
|
|
|
|
|
2017-10-10 01:26:45 +02:00
|
|
|
|
Gbl.Prjs.PrjCod = -1L;
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_StartForm (ActFrmNewPrj);
|
2017-10-10 01:26:45 +02:00
|
|
|
|
Prj_PutCurrentParams ();
|
2017-09-17 16:58:09 +02:00
|
|
|
|
Btn_PutConfirmButton (Txt_New_project);
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_EndForm ();
|
2017-09-15 13:19:27 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-09-23 21:36:08 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************** Put button to create a new project *********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Prj_PutIconToShowAllData (void)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Show_all_data_in_a_table;
|
|
|
|
|
|
2019-01-12 03:00:59 +01:00
|
|
|
|
Lay_PutContextualLinkOnlyIcon (ActSeeTblAllPrj,NULL,Prj_PutCurrentParams,
|
|
|
|
|
"table.svg",
|
|
|
|
|
Txt_Show_all_data_in_a_table);
|
2017-09-23 21:36:08 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-10-06 01:20:05 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************** View / edit file browser of one project *******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2017-10-07 17:09:35 +02:00
|
|
|
|
void Prj_ShowOneUniqueProject (struct Project *Prj)
|
2017-10-06 01:20:05 +02:00
|
|
|
|
{
|
2019-10-20 22:00:28 +02:00
|
|
|
|
/***** Begin table *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TABLE_BeginWidePadding (2);
|
2017-10-06 01:20:05 +02:00
|
|
|
|
|
2017-10-07 17:09:35 +02:00
|
|
|
|
/***** Write project head *****/
|
2017-10-10 18:25:59 +02:00
|
|
|
|
Prj_ShowProjectsHead (Prj_FILE_BROWSER_PROJECT);
|
2017-10-06 01:20:05 +02:00
|
|
|
|
|
2017-10-07 17:09:35 +02:00
|
|
|
|
/***** Show project *****/
|
2017-10-10 18:25:59 +02:00
|
|
|
|
Prj_ShowOneProject (0,Prj,Prj_FILE_BROWSER_PROJECT);
|
2017-10-06 20:56:01 +02:00
|
|
|
|
|
2017-10-07 17:09:35 +02:00
|
|
|
|
/***** End table *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TABLE_End ();
|
2017-10-06 01:20:05 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-09-15 13:19:27 +02:00
|
|
|
|
/*****************************************************************************/
|
2017-09-17 16:58:09 +02:00
|
|
|
|
/********************** Show print view of one project ***********************/
|
2017-09-15 13:19:27 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Prj_PrintOneProject (void)
|
|
|
|
|
{
|
2017-09-19 01:12:05 +02:00
|
|
|
|
struct Project Prj;
|
|
|
|
|
|
|
|
|
|
/***** Allocate memory for the project *****/
|
|
|
|
|
Prj_AllocMemProject (&Prj);
|
2017-09-15 13:19:27 +02:00
|
|
|
|
|
2017-10-06 01:20:05 +02:00
|
|
|
|
/***** Get project data *****/
|
2017-09-19 01:12:05 +02:00
|
|
|
|
Prj.PrjCod = Prj_GetParamPrjCod ();
|
2017-10-06 01:20:05 +02:00
|
|
|
|
Prj_GetDataOfProjectByCod (&Prj);
|
2017-09-15 13:19:27 +02:00
|
|
|
|
|
|
|
|
|
/***** Write header *****/
|
|
|
|
|
Lay_WriteHeaderClassPhoto (true,false,
|
2019-04-03 20:57:04 +02:00
|
|
|
|
Gbl.Hierarchy.Ins.InsCod,
|
|
|
|
|
Gbl.Hierarchy.Deg.DegCod,
|
2019-04-04 10:45:15 +02:00
|
|
|
|
Gbl.Hierarchy.Crs.CrsCod);
|
2017-09-15 13:19:27 +02:00
|
|
|
|
|
|
|
|
|
/***** Table head *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TABLE_BeginWideMarginPadding (2);
|
2017-10-10 18:25:59 +02:00
|
|
|
|
Prj_ShowProjectsHead (Prj_PRINT_ONE_PROJECT);
|
2017-09-15 13:19:27 +02:00
|
|
|
|
|
|
|
|
|
/***** Write project *****/
|
2017-10-10 18:25:59 +02:00
|
|
|
|
Prj_ShowOneProject (0,&Prj,Prj_PRINT_ONE_PROJECT);
|
2017-09-15 13:19:27 +02:00
|
|
|
|
|
|
|
|
|
/***** End table *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TABLE_End ();
|
2017-09-19 01:12:05 +02:00
|
|
|
|
|
|
|
|
|
/***** Free memory of the project *****/
|
|
|
|
|
Prj_FreeMemProject (&Prj);
|
2017-09-15 13:19:27 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2017-09-17 16:58:09 +02:00
|
|
|
|
/***************************** Show one project ******************************/
|
2017-09-15 13:19:27 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2017-10-10 18:25:59 +02:00
|
|
|
|
static void Prj_ShowOneProject (unsigned NumIndex,struct Project *Prj,
|
|
|
|
|
Prj_ProjectView_t ProjectView)
|
2017-09-15 13:19:27 +02:00
|
|
|
|
{
|
2017-10-08 16:12:58 +02:00
|
|
|
|
extern const char *Txt_Project_files;
|
2019-10-25 01:15:11 +02:00
|
|
|
|
extern const char *Txt_Assigned_QUESTION;
|
2017-09-15 13:19:27 +02:00
|
|
|
|
extern const char *Txt_Yes;
|
|
|
|
|
extern const char *Txt_No;
|
2019-10-25 22:48:34 +02:00
|
|
|
|
extern const char *Txt_PROJECT_ASSIGNED_NONASSIGNED_SINGUL[Prj_NUM_ASSIGNED_NONASSIG];
|
2017-10-02 02:19:14 +02:00
|
|
|
|
extern const char *Txt_Number_of_students;
|
2017-10-01 18:44:50 +02:00
|
|
|
|
extern const char *Txt_See_more;
|
|
|
|
|
extern const char *Txt_See_less;
|
2017-10-02 19:34:31 +02:00
|
|
|
|
extern const char *Txt_Proposal;
|
|
|
|
|
extern const char *Txt_PROJECT_STATUS[Prj_NUM_PROPOSAL_TYPES];
|
2017-09-19 09:55:09 +02:00
|
|
|
|
extern const char *Txt_Description;
|
|
|
|
|
extern const char *Txt_Required_knowledge;
|
|
|
|
|
extern const char *Txt_Required_materials;
|
2019-04-20 13:37:01 +02:00
|
|
|
|
char *Anchor = NULL;
|
2019-04-11 15:24:05 +02:00
|
|
|
|
bool ICanViewProjectFiles = Prj_CheckIfICanViewProjectFiles (Prj_GetMyRolesInProject (Prj->PrjCod));
|
2019-10-14 00:45:46 +02:00
|
|
|
|
const char *ClassLabel;
|
|
|
|
|
const char *ClassDate;
|
|
|
|
|
const char *ClassTitle;
|
2019-11-18 20:12:10 +01:00
|
|
|
|
const char *ClassLink;
|
2019-10-14 00:45:46 +02:00
|
|
|
|
const char *ClassData;
|
2019-10-17 00:18:31 +02:00
|
|
|
|
struct Prj_Faults Faults;
|
|
|
|
|
bool PrjIsFaulty;
|
2019-10-14 00:45:46 +02:00
|
|
|
|
static unsigned UniqueId = 0;
|
2019-11-01 22:53:39 +01:00
|
|
|
|
char *Id;
|
2019-10-14 00:45:46 +02:00
|
|
|
|
|
|
|
|
|
/***** Set CSS classes *****/
|
|
|
|
|
ClassLabel = (Prj->Hidden == Prj_HIDDEN) ? "ASG_LABEL_LIGHT" :
|
|
|
|
|
"ASG_LABEL";
|
2019-11-18 20:12:10 +01:00
|
|
|
|
ClassDate = (Prj->Hidden == Prj_HIDDEN) ? "DATE_BLUE_LIGHT" :
|
|
|
|
|
"DATE_BLUE";
|
2019-10-14 00:45:46 +02:00
|
|
|
|
ClassTitle = (Prj->Hidden == Prj_HIDDEN) ? "ASG_TITLE_LIGHT" :
|
|
|
|
|
"ASG_TITLE";
|
2019-12-13 18:22:59 +01:00
|
|
|
|
ClassLink = (Prj->Hidden == Prj_HIDDEN) ? "BT_LINK LT ASG_TITLE_LIGHT" :
|
|
|
|
|
"BT_LINK LT ASG_TITLE";
|
2019-11-18 20:12:10 +01:00
|
|
|
|
ClassData = (Prj->Hidden == Prj_HIDDEN) ? "DAT_LIGHT" :
|
|
|
|
|
"DAT";
|
2017-09-15 13:19:27 +02:00
|
|
|
|
|
2019-04-20 13:37:01 +02:00
|
|
|
|
/***** Set anchor string *****/
|
2019-04-20 21:11:44 +02:00
|
|
|
|
Frm_SetAnchorStr (Prj->PrjCod,&Anchor);
|
2019-04-20 13:37:01 +02:00
|
|
|
|
|
2019-10-17 00:18:31 +02:00
|
|
|
|
/***** Check if project is faulty or faultless *****/
|
|
|
|
|
PrjIsFaulty = Prj_CheckIfPrjIsFaulty (Prj->PrjCod,&Faults);
|
2019-10-14 02:21:41 +02:00
|
|
|
|
|
2017-09-15 13:19:27 +02:00
|
|
|
|
/***** Write first row of data of this project *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_Begin (NULL);
|
2017-10-10 18:25:59 +02:00
|
|
|
|
|
|
|
|
|
/* Number of project */
|
|
|
|
|
switch (ProjectView)
|
|
|
|
|
{
|
|
|
|
|
case Prj_LIST_PROJECTS:
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("rowspan=\"3\" class=\"BIG_INDEX RT COLOR%u\"",
|
2019-10-10 23:14:13 +02:00
|
|
|
|
Gbl.RowEvenOdd);
|
2019-11-10 13:31:47 +01:00
|
|
|
|
HTM_Unsigned (NumIndex);
|
2019-10-14 02:21:41 +02:00
|
|
|
|
|
2019-10-17 00:18:31 +02:00
|
|
|
|
if (PrjIsFaulty)
|
2019-10-14 02:21:41 +02:00
|
|
|
|
{
|
2019-11-09 21:08:20 +01:00
|
|
|
|
HTM_BR ();
|
2019-10-14 02:21:41 +02:00
|
|
|
|
Prj_PutWarningIcon ();
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2017-10-10 18:25:59 +02:00
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-15 13:19:27 +02:00
|
|
|
|
/* Forms to remove/edit this project */
|
2017-10-07 18:11:49 +02:00
|
|
|
|
switch (ProjectView)
|
2017-09-15 13:19:27 +02:00
|
|
|
|
{
|
2017-10-07 18:11:49 +02:00
|
|
|
|
case Prj_LIST_PROJECTS:
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("rowspan=\"3\" class=\"CONTEXT_COL COLOR%u\"",Gbl.RowEvenOdd);
|
2019-10-09 21:05:58 +02:00
|
|
|
|
Prj_PutFormsToRemEditOnePrj (Prj,Anchor,ICanViewProjectFiles);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2019-10-09 21:05:58 +02:00
|
|
|
|
break;
|
2017-10-07 18:11:49 +02:00
|
|
|
|
case Prj_FILE_BROWSER_PROJECT:
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("rowspan=\"3\" class=\"CONTEXT_COL\"");
|
2019-04-20 13:37:01 +02:00
|
|
|
|
Prj_PutFormsToRemEditOnePrj (Prj,Anchor,ICanViewProjectFiles);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2019-04-17 12:40:04 +02:00
|
|
|
|
break;
|
2017-10-07 18:11:49 +02:00
|
|
|
|
default:
|
|
|
|
|
break;
|
2017-09-15 13:19:27 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-10-07 22:08:38 +02:00
|
|
|
|
/* Creation date/time */
|
2017-09-15 13:19:27 +02:00
|
|
|
|
UniqueId++;
|
2019-11-01 22:53:39 +01:00
|
|
|
|
if (asprintf (&Id,"prj_creat_%u",UniqueId) < 0)
|
|
|
|
|
Lay_NotEnoughMemoryExit ();
|
2019-10-09 21:05:58 +02:00
|
|
|
|
switch (ProjectView)
|
|
|
|
|
{
|
|
|
|
|
case Prj_LIST_PROJECTS:
|
2019-11-01 22:53:39 +01:00
|
|
|
|
HTM_TD_Begin ("id=\"%s\" class=\"%s LT COLOR%u\"",
|
|
|
|
|
Id,ClassDate,Gbl.RowEvenOdd);
|
2019-10-09 21:05:58 +02:00
|
|
|
|
break;
|
|
|
|
|
default:
|
2019-11-01 22:53:39 +01:00
|
|
|
|
HTM_TD_Begin ("id=\"%s\" class=\"%s LT\"",
|
|
|
|
|
Id,ClassDate);
|
2019-10-09 21:05:58 +02:00
|
|
|
|
break;
|
|
|
|
|
}
|
2019-11-01 23:35:55 +01:00
|
|
|
|
Dat_WriteLocalDateHMSFromUTC (Id,Prj->CreatTime,
|
2019-11-02 12:10:58 +01:00
|
|
|
|
Gbl.Prefs.DateFormat,Dat_SEPARATOR_BREAK,
|
2019-11-02 11:45:41 +01:00
|
|
|
|
true,true,true,0x7);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2019-11-06 19:45:20 +01:00
|
|
|
|
free (Id);
|
2017-09-15 13:19:27 +02:00
|
|
|
|
|
2017-10-07 22:08:38 +02:00
|
|
|
|
/* Modification date/time */
|
2017-09-15 13:19:27 +02:00
|
|
|
|
UniqueId++;
|
2019-11-01 22:53:39 +01:00
|
|
|
|
if (asprintf (&Id,"prj_modif_%u",UniqueId) < 0)
|
|
|
|
|
Lay_NotEnoughMemoryExit ();
|
2019-10-09 21:05:58 +02:00
|
|
|
|
switch (ProjectView)
|
|
|
|
|
{
|
|
|
|
|
case Prj_LIST_PROJECTS:
|
2019-11-01 22:53:39 +01:00
|
|
|
|
HTM_TD_Begin ("id=\"%s\" class=\"%s LT COLOR%u\"",
|
|
|
|
|
Id,ClassDate,Gbl.RowEvenOdd);
|
2019-10-09 21:05:58 +02:00
|
|
|
|
break;
|
|
|
|
|
default:
|
2019-11-01 22:53:39 +01:00
|
|
|
|
HTM_TD_Begin ("id=\"%s\" class=\"%s LT\"",
|
|
|
|
|
Id,ClassDate);
|
2019-10-09 21:05:58 +02:00
|
|
|
|
break;
|
|
|
|
|
}
|
2019-11-01 23:35:55 +01:00
|
|
|
|
Dat_WriteLocalDateHMSFromUTC (Id,Prj->ModifTime,
|
2019-11-02 12:10:58 +01:00
|
|
|
|
Gbl.Prefs.DateFormat,Dat_SEPARATOR_BREAK,
|
2019-11-02 11:45:41 +01:00
|
|
|
|
true,true,true,0x7);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2019-11-06 19:45:20 +01:00
|
|
|
|
free (Id);
|
2017-09-15 13:19:27 +02:00
|
|
|
|
|
|
|
|
|
/* Project title */
|
2019-10-09 21:05:58 +02:00
|
|
|
|
switch (ProjectView)
|
|
|
|
|
{
|
|
|
|
|
case Prj_LIST_PROJECTS:
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"%s LT COLOR%u\"",ClassTitle,Gbl.RowEvenOdd);
|
2019-10-09 21:05:58 +02:00
|
|
|
|
break;
|
|
|
|
|
default:
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"%s LT\"",ClassTitle);
|
2019-10-09 21:05:58 +02:00
|
|
|
|
break;
|
|
|
|
|
}
|
2019-10-26 01:56:36 +02:00
|
|
|
|
HTM_ARTICLE_Begin (Anchor);
|
2019-10-17 00:18:31 +02:00
|
|
|
|
if (Prj->Title[0])
|
2017-10-07 18:47:46 +02:00
|
|
|
|
{
|
2019-10-14 02:21:41 +02:00
|
|
|
|
if (ICanViewProjectFiles)
|
|
|
|
|
{
|
|
|
|
|
Frm_StartForm (ActAdmDocPrj);
|
|
|
|
|
Prj_PutCurrentParams ();
|
2019-11-20 10:17:42 +01:00
|
|
|
|
HTM_BUTTON_SUBMIT_Begin (Txt_Project_files,ClassLink,NULL);
|
2019-11-10 12:36:37 +01:00
|
|
|
|
HTM_Txt (Prj->Title);
|
2019-11-18 20:12:10 +01:00
|
|
|
|
HTM_BUTTON_End ();
|
2019-10-14 02:21:41 +02:00
|
|
|
|
Frm_EndForm ();
|
|
|
|
|
}
|
|
|
|
|
else
|
2019-11-10 12:36:37 +01:00
|
|
|
|
HTM_Txt (Prj->Title);
|
2017-10-07 18:47:46 +02:00
|
|
|
|
}
|
2019-10-17 00:18:31 +02:00
|
|
|
|
if (Faults.WrongTitle)
|
|
|
|
|
Prj_PutWarningIcon ();
|
2019-10-26 01:56:36 +02:00
|
|
|
|
HTM_ARTICLE_End ();
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2017-09-15 13:19:27 +02:00
|
|
|
|
|
2017-09-22 00:26:14 +02:00
|
|
|
|
/* Department */
|
|
|
|
|
Prj_ShowOneProjectDepartment (Prj,ProjectView);
|
2017-09-15 13:19:27 +02:00
|
|
|
|
|
2019-10-25 22:48:34 +02:00
|
|
|
|
/***** Assigned? *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_Begin (NULL);
|
2019-10-09 21:05:58 +02:00
|
|
|
|
|
2017-10-10 18:25:59 +02:00
|
|
|
|
switch (ProjectView)
|
|
|
|
|
{
|
|
|
|
|
case Prj_LIST_PROJECTS:
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("colspan=\"2\" class=\"RT %s COLOR%u\"",
|
2019-10-14 00:45:46 +02:00
|
|
|
|
ClassLabel,Gbl.RowEvenOdd);
|
2019-10-09 21:05:58 +02:00
|
|
|
|
break;
|
2017-10-10 18:25:59 +02:00
|
|
|
|
default:
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("colspan=\"2\" class=\"RT %s\"",
|
2019-10-14 00:45:46 +02:00
|
|
|
|
ClassLabel);
|
2017-10-10 18:25:59 +02:00
|
|
|
|
break;
|
|
|
|
|
}
|
2019-11-11 10:59:24 +01:00
|
|
|
|
HTM_TxtF ("%s:",Txt_Assigned_QUESTION);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2019-10-07 20:17:29 +02:00
|
|
|
|
|
2017-10-10 18:25:59 +02:00
|
|
|
|
switch (ProjectView)
|
|
|
|
|
{
|
|
|
|
|
case Prj_LIST_PROJECTS:
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("colspan=\"2\" class=\"LT %s COLOR%u\"",
|
2019-10-14 00:45:46 +02:00
|
|
|
|
ClassData,Gbl.RowEvenOdd);
|
2017-10-10 18:25:59 +02:00
|
|
|
|
break;
|
|
|
|
|
default:
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("colspan=\"2\" class=\"LT %s\"",
|
2019-10-14 00:45:46 +02:00
|
|
|
|
ClassData);
|
2017-10-10 18:25:59 +02:00
|
|
|
|
break;
|
|
|
|
|
}
|
2019-11-11 10:59:24 +01:00
|
|
|
|
HTM_TxtF ("%s ",Prj->Assigned == Prj_ASSIGNED ? Txt_Yes :
|
|
|
|
|
Txt_No);
|
2019-10-25 22:48:34 +02:00
|
|
|
|
Ico_PutIconOff (AssignedNonassigImage[Prj->Assigned],
|
|
|
|
|
Txt_PROJECT_ASSIGNED_NONASSIGNED_SINGUL[Prj->Assigned]);
|
2019-10-25 01:15:11 +02:00
|
|
|
|
|
|
|
|
|
if (Faults.WrongAssigned)
|
|
|
|
|
Prj_PutWarningIcon ();
|
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2019-10-09 21:05:58 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_End ();
|
2017-09-21 13:11:58 +02:00
|
|
|
|
|
2017-10-02 02:19:14 +02:00
|
|
|
|
/***** Number of students *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_Begin (NULL);
|
2019-10-09 21:05:58 +02:00
|
|
|
|
|
2017-10-10 18:25:59 +02:00
|
|
|
|
switch (ProjectView)
|
|
|
|
|
{
|
|
|
|
|
case Prj_LIST_PROJECTS:
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("colspan=\"2\" class=\"RT %s COLOR%u\"",
|
2019-10-14 00:45:46 +02:00
|
|
|
|
ClassLabel,Gbl.RowEvenOdd);
|
2017-10-10 18:25:59 +02:00
|
|
|
|
break;
|
|
|
|
|
default:
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("colspan=\"2\" class=\"RT %s\"",
|
2019-10-14 00:45:46 +02:00
|
|
|
|
ClassLabel);
|
2017-10-10 18:25:59 +02:00
|
|
|
|
break;
|
|
|
|
|
}
|
2019-11-11 10:59:24 +01:00
|
|
|
|
HTM_TxtF ("%s:",Txt_Number_of_students);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2019-10-07 20:17:29 +02:00
|
|
|
|
|
2017-10-10 18:25:59 +02:00
|
|
|
|
switch (ProjectView)
|
|
|
|
|
{
|
|
|
|
|
case Prj_LIST_PROJECTS:
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("colspan=\"2\" class=\"LT %s COLOR%u\"",
|
2019-10-14 00:45:46 +02:00
|
|
|
|
ClassData,Gbl.RowEvenOdd);
|
2017-10-10 18:25:59 +02:00
|
|
|
|
break;
|
|
|
|
|
default:
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("colspan=\"2\" class=\"LT %s\"",
|
2019-10-14 00:45:46 +02:00
|
|
|
|
ClassData);
|
2017-10-10 18:25:59 +02:00
|
|
|
|
break;
|
|
|
|
|
}
|
2019-11-10 13:31:47 +01:00
|
|
|
|
HTM_Unsigned (Prj->NumStds);
|
2019-10-17 00:18:31 +02:00
|
|
|
|
if (Faults.WrongNumStds)
|
2019-10-14 02:21:41 +02:00
|
|
|
|
Prj_PutWarningIcon ();
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2019-10-07 20:17:29 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_End ();
|
2017-10-02 02:19:14 +02:00
|
|
|
|
|
|
|
|
|
/***** Project members *****/
|
|
|
|
|
Prj_ShowOneProjectMembers (Prj,ProjectView);
|
|
|
|
|
|
2017-10-01 18:44:50 +02:00
|
|
|
|
/***** Link to show hidden info *****/
|
2017-10-06 01:20:05 +02:00
|
|
|
|
switch (ProjectView)
|
2017-10-01 18:44:50 +02:00
|
|
|
|
{
|
2017-10-06 01:20:05 +02:00
|
|
|
|
case Prj_LIST_PROJECTS:
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_Begin ("id=\"prj_exp_%u\"",UniqueId);
|
|
|
|
|
HTM_TD_Begin ("colspan=\"6\" class=\"CM COLOR%u\"",Gbl.RowEvenOdd);
|
2019-01-11 02:55:01 +01:00
|
|
|
|
Prj_PutIconToToggleProject (UniqueId,"angle-down.svg",Txt_See_more);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
HTM_TR_End ();
|
2017-10-10 18:25:59 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_Begin ("id=\"prj_con_%u\" style=\"display:none;\"",UniqueId);
|
|
|
|
|
HTM_TD_Begin ("colspan=\"6\" class=\"CM COLOR%u\"",Gbl.RowEvenOdd);
|
2019-01-11 02:55:01 +01:00
|
|
|
|
Prj_PutIconToToggleProject (UniqueId,"angle-up.svg",Txt_See_less);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
HTM_TR_End ();
|
2017-10-10 18:25:59 +02:00
|
|
|
|
break;
|
2017-10-06 01:20:05 +02:00
|
|
|
|
case Prj_FILE_BROWSER_PROJECT:
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_Begin ("id=\"prj_exp_%u\"",UniqueId);
|
|
|
|
|
HTM_TD_Begin ("colspan=\"5\" class=\"CM\"");
|
2019-01-11 02:55:01 +01:00
|
|
|
|
Prj_PutIconToToggleProject (UniqueId,"angle-down.svg",Txt_See_more);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
HTM_TR_End ();
|
2017-10-01 18:44:50 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_Begin ("id=\"prj_con_%u\" style=\"display:none;\"",UniqueId);
|
|
|
|
|
HTM_TD_Begin ("colspan=\"5\" class=\"CM\"");
|
2019-01-11 02:55:01 +01:00
|
|
|
|
Prj_PutIconToToggleProject (UniqueId,"angle-up.svg",Txt_See_less);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
HTM_TR_End ();
|
2017-10-06 01:20:05 +02:00
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
2017-10-01 18:44:50 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-10-02 19:34:31 +02:00
|
|
|
|
/***** Proposal *****/
|
2017-10-06 01:20:05 +02:00
|
|
|
|
switch (ProjectView)
|
|
|
|
|
{
|
|
|
|
|
case Prj_LIST_PROJECTS:
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_Begin ("id=\"prj_pro_%u\" style=\"display:none;\"",UniqueId);
|
|
|
|
|
HTM_TD_Begin ("colspan=\"4\" class=\"RT %s COLOR%u\"",
|
2019-10-14 00:45:46 +02:00
|
|
|
|
ClassLabel,Gbl.RowEvenOdd);
|
2017-10-10 18:25:59 +02:00
|
|
|
|
break;
|
2017-10-06 01:20:05 +02:00
|
|
|
|
case Prj_FILE_BROWSER_PROJECT:
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_Begin ("id=\"prj_pro_%u\" style=\"display:none;\"",UniqueId);
|
|
|
|
|
HTM_TD_Begin ("colspan=\"3\" class=\"RT %s\"",ClassLabel);
|
2017-10-06 01:20:05 +02:00
|
|
|
|
break;
|
|
|
|
|
default:
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_Begin (NULL);
|
|
|
|
|
HTM_TD_Begin ("colspan=\"2\" class=\"RT %s\"",ClassLabel);
|
2019-10-04 14:42:59 +02:00
|
|
|
|
break;
|
2017-10-06 01:20:05 +02:00
|
|
|
|
}
|
2019-11-11 10:59:24 +01:00
|
|
|
|
HTM_TxtF ("%s:",Txt_Proposal);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2019-10-07 20:17:29 +02:00
|
|
|
|
|
2019-10-09 21:05:58 +02:00
|
|
|
|
switch (ProjectView)
|
|
|
|
|
{
|
|
|
|
|
case Prj_LIST_PROJECTS:
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("colspan=\"2\" class=\"LT %s COLOR%u\"",
|
2019-10-14 00:45:46 +02:00
|
|
|
|
ClassData,
|
2019-10-10 23:14:13 +02:00
|
|
|
|
Gbl.RowEvenOdd);
|
2019-10-09 21:05:58 +02:00
|
|
|
|
break;
|
|
|
|
|
default:
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("colspan=\"2\" class=\"LT %s\"",
|
2019-10-14 00:45:46 +02:00
|
|
|
|
ClassData);
|
2019-10-09 21:05:58 +02:00
|
|
|
|
break;
|
|
|
|
|
}
|
2019-11-10 12:36:37 +01:00
|
|
|
|
HTM_Txt (Txt_PROJECT_STATUS[Prj->Proposal]);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2019-10-07 20:17:29 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_End ();
|
2017-10-02 01:16:10 +02:00
|
|
|
|
|
2017-10-01 18:44:50 +02:00
|
|
|
|
/***** Write rows of data of this project *****/
|
|
|
|
|
/* Description of the project */
|
|
|
|
|
Prj_ShowOneProjectTxtField (Prj,ProjectView,"prj_dsc_",UniqueId,
|
2019-10-14 02:21:41 +02:00
|
|
|
|
Txt_Description,Prj->Description,
|
2019-10-17 00:18:31 +02:00
|
|
|
|
Faults.WrongDescription);
|
2017-10-01 18:44:50 +02:00
|
|
|
|
|
|
|
|
|
/* Required knowledge to carry out the project */
|
|
|
|
|
Prj_ShowOneProjectTxtField (Prj,ProjectView,"prj_knw_",UniqueId,
|
2019-10-14 02:21:41 +02:00
|
|
|
|
Txt_Required_knowledge,Prj->Knowledge,
|
|
|
|
|
false); // No warning
|
2017-10-01 18:44:50 +02:00
|
|
|
|
|
|
|
|
|
/* Required materials to carry out the project */
|
|
|
|
|
Prj_ShowOneProjectTxtField (Prj,ProjectView,"prj_mtr_",UniqueId,
|
2019-10-14 02:21:41 +02:00
|
|
|
|
Txt_Required_materials,Prj->Materials,
|
|
|
|
|
false); // No warning
|
2017-10-01 18:44:50 +02:00
|
|
|
|
|
|
|
|
|
/* Link to view more info about the project */
|
|
|
|
|
Prj_ShowOneProjectURL (Prj,ProjectView,"prj_url_",UniqueId);
|
|
|
|
|
|
2019-04-20 13:37:01 +02:00
|
|
|
|
/***** Free anchor string *****/
|
2019-04-20 21:11:44 +02:00
|
|
|
|
Frm_FreeAnchorStr (Anchor);
|
2019-04-20 13:37:01 +02:00
|
|
|
|
|
2017-09-24 12:31:48 +02:00
|
|
|
|
Gbl.RowEvenOdd = 1 - Gbl.RowEvenOdd;
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-20 13:37:01 +02:00
|
|
|
|
/*****************************************************************************/
|
2019-10-17 00:18:31 +02:00
|
|
|
|
/********************** Check if a project has faults ************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static bool Prj_CheckIfPrjIsFaulty (long PrjCod,struct Prj_Faults *Faults)
|
|
|
|
|
{
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
|
|
|
|
long LongNum;
|
2019-10-25 22:48:34 +02:00
|
|
|
|
bool IsAssigned;
|
2019-10-17 00:18:31 +02:00
|
|
|
|
bool HasTitle;
|
|
|
|
|
bool HasDescription;
|
|
|
|
|
unsigned NumProposedStds;
|
|
|
|
|
unsigned NumStdsRegisteredInPrj;
|
|
|
|
|
|
|
|
|
|
/***** Reset faults *****/
|
|
|
|
|
Faults->WrongTitle =
|
|
|
|
|
Faults->WrongDescription =
|
2019-10-25 01:15:11 +02:00
|
|
|
|
Faults->WrongNumStds =
|
|
|
|
|
Faults->WrongAssigned = false;
|
2019-10-17 00:18:31 +02:00
|
|
|
|
|
|
|
|
|
/***** Get some project date and check faults ****/
|
|
|
|
|
if (PrjCod > 0)
|
|
|
|
|
{
|
|
|
|
|
/***** Query database *****/
|
|
|
|
|
if (DB_QuerySELECT (&mysql_res,"can not get project data",
|
2019-10-25 22:48:34 +02:00
|
|
|
|
"SELECT Assigned='Y'," // row[0] = 0 / 1
|
2019-10-17 00:18:31 +02:00
|
|
|
|
"NumStds," // row[1] =
|
|
|
|
|
"Title<>''," // row[2] = 0 / 1
|
|
|
|
|
"Description<>''" // row[3] = 0 / 1
|
|
|
|
|
" FROM projects"
|
|
|
|
|
" WHERE PrjCod=%ld",
|
|
|
|
|
PrjCod)) // Project found...
|
|
|
|
|
{
|
|
|
|
|
/***** Get some data of project *****/
|
|
|
|
|
/* Get row */
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
|
|
|
|
|
2019-10-25 22:48:34 +02:00
|
|
|
|
/* Get if project is assigned or not (row[0]) */
|
|
|
|
|
IsAssigned = (row[0][0] != '0');
|
2019-10-17 00:18:31 +02:00
|
|
|
|
|
2019-10-25 22:48:34 +02:00
|
|
|
|
/* Get if project is assigned or not (row[1]) */
|
2019-10-17 00:18:31 +02:00
|
|
|
|
LongNum = Str_ConvertStrCodToLongCod (row[1]);
|
|
|
|
|
NumProposedStds = (LongNum > 0) ? (unsigned) LongNum :
|
|
|
|
|
0;
|
|
|
|
|
|
|
|
|
|
/* Get the title of the project (row[2]) */
|
|
|
|
|
HasTitle = (row[2][0] != '0');
|
|
|
|
|
|
|
|
|
|
/* Get the description of the project (row[3]) */
|
|
|
|
|
HasDescription = (row[3][0] != '0');
|
|
|
|
|
|
|
|
|
|
/***** Check faults *****/
|
|
|
|
|
/* 1. Check title */
|
|
|
|
|
Faults->WrongTitle = !HasTitle;
|
|
|
|
|
|
|
|
|
|
/* 2. Check description */
|
|
|
|
|
Faults->WrongDescription = !HasDescription;
|
|
|
|
|
|
|
|
|
|
/* 3. Check number of students */
|
|
|
|
|
if (NumProposedStds == 0)
|
2019-10-25 01:15:11 +02:00
|
|
|
|
// The number of proposed students should be > 0
|
2019-10-17 00:18:31 +02:00
|
|
|
|
Faults->WrongNumStds = true;
|
2019-10-25 01:15:11 +02:00
|
|
|
|
else
|
2019-10-17 00:18:31 +02:00
|
|
|
|
{
|
|
|
|
|
NumStdsRegisteredInPrj = Prj_GetNumUsrsInPrj (PrjCod,Prj_ROLE_STD);
|
2019-10-25 22:48:34 +02:00
|
|
|
|
if (IsAssigned) // Assigned
|
2019-10-25 01:15:11 +02:00
|
|
|
|
// In an assigned project the number of proposed students...
|
|
|
|
|
// ...should match the number of students registered in it
|
|
|
|
|
Faults->WrongNumStds = (NumProposedStds != NumStdsRegisteredInPrj);
|
|
|
|
|
else // Not assigned
|
|
|
|
|
// A non assigned project should not have students registered in it
|
|
|
|
|
Faults->WrongAssigned = (NumStdsRegisteredInPrj != 0);
|
2019-10-17 00:18:31 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Faults->WrongTitle ||
|
|
|
|
|
Faults->WrongDescription ||
|
2019-10-25 01:15:11 +02:00
|
|
|
|
Faults->WrongNumStds ||
|
|
|
|
|
Faults->WrongAssigned;
|
2019-10-17 00:18:31 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************** Put an icon to warn about a fault in a project ***************/
|
2017-10-01 18:44:50 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2019-10-14 02:21:41 +02:00
|
|
|
|
static void Prj_PutWarningIcon (void)
|
|
|
|
|
{
|
2019-10-29 21:41:54 +01:00
|
|
|
|
Ico_PutIcon ("warning64x64.gif","","ICO16x16");
|
2019-10-14 02:21:41 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********** Put an icon to toggle on/off some fields of a project ************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2017-10-01 18:44:50 +02:00
|
|
|
|
static void Prj_PutIconToToggleProject (unsigned UniqueId,
|
|
|
|
|
const char *Icon,const char *Text)
|
|
|
|
|
{
|
2019-02-22 21:47:50 +01:00
|
|
|
|
extern const char *The_ClassFormInBox[The_NUM_THEMES];
|
2017-10-01 18:44:50 +02:00
|
|
|
|
|
|
|
|
|
/***** Link to toggle on/off some fields of project *****/
|
2019-10-28 20:38:29 +01:00
|
|
|
|
HTM_A_Begin ("href=\"\" title=\"%s\" class=\"%s\""
|
|
|
|
|
" onclick=\"toggleProject('%u');return false;\"",
|
|
|
|
|
Text,The_ClassFormInBox[Gbl.Prefs.Theme],
|
|
|
|
|
UniqueId);
|
2019-01-12 19:46:33 +01:00
|
|
|
|
Ico_PutIconTextLink (Icon,Text);
|
2019-10-28 13:56:04 +01:00
|
|
|
|
HTM_A_End ();
|
2017-10-01 18:44:50 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-09-24 12:31:48 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************** Show one row of table with all projects *******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Prj_ShowTableAllProjectsOneRow (struct Project *Prj)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Yes;
|
|
|
|
|
extern const char *Txt_No;
|
2017-10-02 19:34:31 +02:00
|
|
|
|
extern const char *Txt_PROJECT_STATUS[Prj_NUM_PROPOSAL_TYPES];
|
2017-10-01 00:48:36 +02:00
|
|
|
|
unsigned NumRoleToShow;
|
2019-10-14 00:45:46 +02:00
|
|
|
|
const char *ClassDate;
|
|
|
|
|
const char *ClassData;
|
2017-09-24 12:31:48 +02:00
|
|
|
|
static unsigned UniqueId = 0;
|
2019-11-01 22:53:39 +01:00
|
|
|
|
char *Id;
|
2017-09-24 12:31:48 +02:00
|
|
|
|
|
|
|
|
|
/***** Get data of this project *****/
|
|
|
|
|
Prj_GetDataOfProjectByCod (Prj);
|
|
|
|
|
|
2019-10-14 00:45:46 +02:00
|
|
|
|
/***** Set CSS classes *****/
|
|
|
|
|
ClassDate = (Prj->Hidden == Prj_HIDDEN) ? "DATE_BLUE_LIGHT" :
|
|
|
|
|
"DATE_BLUE";
|
|
|
|
|
ClassData = (Prj->Hidden == Prj_HIDDEN) ? "DAT_LIGHT" :
|
|
|
|
|
"DAT";
|
|
|
|
|
|
2017-09-24 12:31:48 +02:00
|
|
|
|
/***** Start row *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_Begin (NULL);
|
2017-09-24 12:31:48 +02:00
|
|
|
|
|
|
|
|
|
/***** Start date/time *****/
|
|
|
|
|
UniqueId++;
|
2019-11-01 22:53:39 +01:00
|
|
|
|
if (asprintf (&Id,"prj_creat_%u",UniqueId) < 0)
|
|
|
|
|
Lay_NotEnoughMemoryExit ();
|
|
|
|
|
HTM_TD_Begin ("id=\"%s\" class=\"LT %s COLOR%u\"",
|
|
|
|
|
Id,ClassDate,Gbl.RowEvenOdd);
|
2019-11-01 23:35:55 +01:00
|
|
|
|
Dat_WriteLocalDateHMSFromUTC (Id,Prj->CreatTime,
|
2019-11-02 12:10:58 +01:00
|
|
|
|
Gbl.Prefs.DateFormat,Dat_SEPARATOR_BREAK,
|
2019-11-11 13:11:38 +01:00
|
|
|
|
true,true,false,0x7);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2019-11-06 19:45:20 +01:00
|
|
|
|
free (Id);
|
2017-09-24 12:31:48 +02:00
|
|
|
|
|
|
|
|
|
/***** End date/time *****/
|
|
|
|
|
UniqueId++;
|
2019-11-01 22:53:39 +01:00
|
|
|
|
if (asprintf (&Id,"prj_modif_%u",UniqueId) < 0)
|
|
|
|
|
Lay_NotEnoughMemoryExit ();
|
|
|
|
|
HTM_TD_Begin ("id=\"%s\" class=\"LT %s COLOR%u\"",
|
|
|
|
|
Id,ClassDate,Gbl.RowEvenOdd);
|
2019-11-01 23:35:55 +01:00
|
|
|
|
Dat_WriteLocalDateHMSFromUTC (Id,Prj->ModifTime,
|
2019-11-02 12:10:58 +01:00
|
|
|
|
Gbl.Prefs.DateFormat,Dat_SEPARATOR_BREAK,
|
2019-11-11 13:11:38 +01:00
|
|
|
|
true,true,false,0x7);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2019-11-06 19:45:20 +01:00
|
|
|
|
free (Id);
|
2017-09-24 12:31:48 +02:00
|
|
|
|
|
|
|
|
|
/***** Project title *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"LT %s COLOR%u\"",
|
2019-10-14 00:45:46 +02:00
|
|
|
|
ClassData,
|
2019-10-10 23:14:13 +02:00
|
|
|
|
Gbl.RowEvenOdd);
|
2019-11-10 12:36:37 +01:00
|
|
|
|
HTM_Txt (Prj->Title);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2017-09-24 12:31:48 +02:00
|
|
|
|
|
2017-10-01 18:44:50 +02:00
|
|
|
|
/***** Department *****/
|
2017-09-24 12:31:48 +02:00
|
|
|
|
Prj_ShowTableAllProjectsDepartment (Prj);
|
|
|
|
|
|
2019-10-25 22:48:34 +02:00
|
|
|
|
/***** Assigned? *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"LT %s COLOR%u\"",ClassData,Gbl.RowEvenOdd);
|
2019-11-10 12:36:37 +01:00
|
|
|
|
HTM_Txt ((Prj->Assigned == Prj_ASSIGNED) ? Txt_Yes :
|
|
|
|
|
Txt_No);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2017-09-24 12:31:48 +02:00
|
|
|
|
|
2017-10-02 02:19:14 +02:00
|
|
|
|
/***** Number of students *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"LT %s COLOR%u\"",ClassData,Gbl.RowEvenOdd);
|
2019-11-10 13:31:47 +01:00
|
|
|
|
HTM_Unsigned (Prj->NumStds);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2017-10-02 01:16:10 +02:00
|
|
|
|
|
2017-10-01 18:44:50 +02:00
|
|
|
|
/***** Project members *****/
|
2017-10-01 00:48:36 +02:00
|
|
|
|
for (NumRoleToShow = 0;
|
|
|
|
|
NumRoleToShow < Brw_NUM_ROLES_TO_SHOW;
|
|
|
|
|
NumRoleToShow++)
|
|
|
|
|
Prj_ShowTableAllProjectsMembersWithARole (Prj,Prj_RolesToShow[NumRoleToShow]);
|
2017-09-24 12:31:48 +02:00
|
|
|
|
|
2017-10-02 19:34:31 +02:00
|
|
|
|
/***** Proposal *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"LT %s COLOR%u\"",ClassData,Gbl.RowEvenOdd);
|
2019-11-10 12:36:37 +01:00
|
|
|
|
HTM_Txt (Txt_PROJECT_STATUS[Prj->Proposal]);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2017-10-02 02:19:14 +02:00
|
|
|
|
|
2017-10-01 18:44:50 +02:00
|
|
|
|
/***** Write rows of data of this project *****/
|
|
|
|
|
/* Description of the project */
|
|
|
|
|
Prj_ShowTableAllProjectsTxtField (Prj,Prj->Description);
|
|
|
|
|
|
|
|
|
|
/* Required knowledge to carry out the project */
|
|
|
|
|
Prj_ShowTableAllProjectsTxtField (Prj,Prj->Knowledge);
|
|
|
|
|
|
|
|
|
|
/* Required materials to carry out the project */
|
|
|
|
|
Prj_ShowTableAllProjectsTxtField (Prj,Prj->Materials);
|
|
|
|
|
|
|
|
|
|
/* Link to view more info about the project */
|
|
|
|
|
Prj_ShowTableAllProjectsURL (Prj);
|
|
|
|
|
|
2017-09-24 12:31:48 +02:00
|
|
|
|
/***** End row *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_End ();
|
2017-09-21 21:10:52 +02:00
|
|
|
|
|
2017-09-20 14:06:24 +02:00
|
|
|
|
Gbl.RowEvenOdd = 1 - Gbl.RowEvenOdd;
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-22 00:26:14 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/****************** Show department associated to project ********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Prj_ShowOneProjectDepartment (const struct Project *Prj,
|
|
|
|
|
Prj_ProjectView_t ProjectView)
|
|
|
|
|
{
|
|
|
|
|
struct Department Dpt;
|
2017-09-23 21:36:08 +02:00
|
|
|
|
bool PutLink;
|
2019-10-14 00:45:46 +02:00
|
|
|
|
const char *ClassData;
|
|
|
|
|
|
|
|
|
|
/***** Set CSS classes *****/
|
|
|
|
|
ClassData = (Prj->Hidden == Prj_HIDDEN) ? "DAT_LIGHT" :
|
|
|
|
|
"DAT";
|
2017-09-22 00:26:14 +02:00
|
|
|
|
|
|
|
|
|
/***** Get data of department *****/
|
|
|
|
|
Dpt.DptCod = Prj->DptCod;
|
|
|
|
|
Dpt_GetDataOfDepartmentByCod (&Dpt);
|
|
|
|
|
|
|
|
|
|
/***** Show department *****/
|
2017-10-10 18:25:59 +02:00
|
|
|
|
PutLink = (Dpt.WWW[0] &&
|
|
|
|
|
(ProjectView == Prj_LIST_PROJECTS ||
|
|
|
|
|
ProjectView == Prj_FILE_BROWSER_PROJECT));
|
2017-09-23 21:36:08 +02:00
|
|
|
|
|
2019-10-09 21:05:58 +02:00
|
|
|
|
switch (ProjectView)
|
|
|
|
|
{
|
|
|
|
|
case Prj_LIST_PROJECTS:
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"LT %s COLOR%u\"",ClassData,Gbl.RowEvenOdd);
|
2019-10-09 21:05:58 +02:00
|
|
|
|
break;
|
|
|
|
|
default:
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"LT %s\"",ClassData);
|
2019-10-09 21:05:58 +02:00
|
|
|
|
break;
|
|
|
|
|
}
|
2017-09-23 21:36:08 +02:00
|
|
|
|
if (PutLink)
|
2019-10-28 20:38:29 +01:00
|
|
|
|
HTM_A_Begin ("href=\"%s\" target=\"_blank\" class=\"%s\"",
|
|
|
|
|
Dpt.WWW,ClassData);
|
2019-11-10 12:36:37 +01:00
|
|
|
|
HTM_Txt (Dpt.FullName);
|
2017-09-23 21:36:08 +02:00
|
|
|
|
if (PutLink)
|
2019-10-28 13:56:04 +01:00
|
|
|
|
HTM_A_End ();
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
HTM_TR_End ();
|
2017-09-22 00:26:14 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-09-24 12:31:48 +02:00
|
|
|
|
static void Prj_ShowTableAllProjectsDepartment (const struct Project *Prj)
|
|
|
|
|
{
|
|
|
|
|
struct Department Dpt;
|
2019-10-14 00:45:46 +02:00
|
|
|
|
const char *ClassData;
|
|
|
|
|
|
|
|
|
|
/***** Set CSS classes *****/
|
|
|
|
|
ClassData = (Prj->Hidden == Prj_HIDDEN) ? "DAT_LIGHT" :
|
|
|
|
|
"DAT";
|
2017-09-24 12:31:48 +02:00
|
|
|
|
|
|
|
|
|
/***** Get data of department *****/
|
|
|
|
|
Dpt.DptCod = Prj->DptCod;
|
|
|
|
|
Dpt_GetDataOfDepartmentByCod (&Dpt);
|
|
|
|
|
|
|
|
|
|
/***** Show department *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"LT %s COLOR%u\"",ClassData,Gbl.RowEvenOdd);
|
2019-11-10 12:36:37 +01:00
|
|
|
|
HTM_Txt (Dpt.FullName);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2017-09-24 12:31:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-09-20 14:06:24 +02:00
|
|
|
|
/*****************************************************************************/
|
2017-09-24 12:31:48 +02:00
|
|
|
|
/********************** Show text field about a project **********************/
|
2017-09-20 14:06:24 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2017-09-24 12:31:48 +02:00
|
|
|
|
static void Prj_ShowOneProjectTxtField (struct Project *Prj,
|
|
|
|
|
Prj_ProjectView_t ProjectView,
|
2017-10-01 18:44:50 +02:00
|
|
|
|
const char *id,unsigned UniqueId,
|
2019-10-14 02:21:41 +02:00
|
|
|
|
const char *Label,char *TxtField,
|
|
|
|
|
bool Warning)
|
2017-09-20 14:06:24 +02:00
|
|
|
|
{
|
2019-10-14 00:45:46 +02:00
|
|
|
|
const char *ClassLabel;
|
|
|
|
|
const char *ClassData;
|
|
|
|
|
|
|
|
|
|
/***** Set CSS classes *****/
|
|
|
|
|
ClassLabel = (Prj->Hidden == Prj_HIDDEN) ? "ASG_LABEL_LIGHT" :
|
|
|
|
|
"ASG_LABEL";
|
|
|
|
|
ClassData = (Prj->Hidden == Prj_HIDDEN) ? "DAT_LIGHT" :
|
|
|
|
|
"DAT";
|
|
|
|
|
|
2019-10-14 02:21:41 +02:00
|
|
|
|
/***** Label *****/
|
2017-10-06 01:20:05 +02:00
|
|
|
|
switch (ProjectView)
|
|
|
|
|
{
|
|
|
|
|
case Prj_LIST_PROJECTS:
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_Begin ("id=\"%s%u\" style=\"display:none;\"",id,UniqueId);
|
|
|
|
|
HTM_TD_Begin ("colspan=\"4\" class=\"RT %s COLOR%u\"",ClassLabel,Gbl.RowEvenOdd);
|
2017-10-10 18:25:59 +02:00
|
|
|
|
break;
|
2017-10-06 01:20:05 +02:00
|
|
|
|
case Prj_FILE_BROWSER_PROJECT:
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_Begin ("id=\"%s%u\" style=\"display:none;\"",id,UniqueId);
|
|
|
|
|
HTM_TD_Begin ("colspan=\"3\" class=\"RT %s\"",ClassLabel);
|
2017-10-06 01:20:05 +02:00
|
|
|
|
break;
|
2017-10-10 18:25:59 +02:00
|
|
|
|
case Prj_PRINT_ONE_PROJECT:
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_Begin (NULL);
|
|
|
|
|
HTM_TD_Begin ("colspan=\"2\" class=\"RT %s\"",ClassLabel);
|
2017-10-10 18:25:59 +02:00
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
// Not applicable
|
2017-10-06 01:20:05 +02:00
|
|
|
|
break;
|
|
|
|
|
}
|
2019-11-11 10:59:24 +01:00
|
|
|
|
HTM_TxtF ("%s:",Label);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2019-10-07 20:17:29 +02:00
|
|
|
|
|
2019-10-14 02:21:41 +02:00
|
|
|
|
/***** Change text format *****/
|
|
|
|
|
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
|
|
|
|
|
TxtField,Cns_MAX_BYTES_TEXT,false); // Convert from HTML to recpectful HTML
|
|
|
|
|
switch (ProjectView)
|
|
|
|
|
{
|
|
|
|
|
case Prj_LIST_PROJECTS:
|
|
|
|
|
case Prj_FILE_BROWSER_PROJECT:
|
|
|
|
|
Str_InsertLinks (TxtField,Cns_MAX_BYTES_TEXT,60); // Insert links
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Text *****/
|
2019-10-09 21:05:58 +02:00
|
|
|
|
switch (ProjectView)
|
|
|
|
|
{
|
|
|
|
|
case Prj_LIST_PROJECTS:
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("colspan=\"2\" class=\"LT %s COLOR%u\"",
|
2019-10-14 00:45:46 +02:00
|
|
|
|
ClassData,Gbl.RowEvenOdd);
|
2019-10-09 21:05:58 +02:00
|
|
|
|
break;
|
|
|
|
|
default:
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("colspan=\"2\" class=\"LT %s\"",
|
2019-10-14 00:45:46 +02:00
|
|
|
|
ClassData);
|
2019-10-09 21:05:58 +02:00
|
|
|
|
break;
|
|
|
|
|
}
|
2019-11-10 12:36:37 +01:00
|
|
|
|
HTM_Txt (TxtField);
|
2019-10-14 02:21:41 +02:00
|
|
|
|
if (Warning)
|
|
|
|
|
Prj_PutWarningIcon ();
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2019-10-07 20:17:29 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_End ();
|
2017-09-15 13:19:27 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-09-24 12:31:48 +02:00
|
|
|
|
static void Prj_ShowTableAllProjectsTxtField (struct Project *Prj,
|
|
|
|
|
char *TxtField)
|
|
|
|
|
{
|
2019-10-14 00:45:46 +02:00
|
|
|
|
const char *ClassData;
|
|
|
|
|
|
|
|
|
|
/***** Set CSS classes *****/
|
|
|
|
|
ClassData = (Prj->Hidden == Prj_HIDDEN) ? "DAT_LIGHT" :
|
|
|
|
|
"DAT";
|
|
|
|
|
|
2017-09-24 12:31:48 +02:00
|
|
|
|
/***** Change format *****/
|
|
|
|
|
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
|
|
|
|
|
TxtField,Cns_MAX_BYTES_TEXT,false); // Convert from HTML to recpectful HTML
|
|
|
|
|
|
|
|
|
|
/***** Write text *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"LT %s COLOR%u\"",ClassData,Gbl.RowEvenOdd);
|
2019-11-10 12:36:37 +01:00
|
|
|
|
HTM_Txt (TxtField);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2017-09-24 12:31:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-09-24 18:51:56 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************** Show URL associated to project ***********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Prj_ShowOneProjectURL (const struct Project *Prj,
|
2017-10-01 18:44:50 +02:00
|
|
|
|
Prj_ProjectView_t ProjectView,
|
|
|
|
|
const char *id,unsigned UniqueId)
|
2017-09-24 18:51:56 +02:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_URL;
|
2019-10-14 00:45:46 +02:00
|
|
|
|
const char *ClassLabel;
|
|
|
|
|
const char *ClassData;
|
2017-10-10 18:25:59 +02:00
|
|
|
|
bool PutLink = (Prj->URL[0] &&
|
|
|
|
|
(ProjectView == Prj_LIST_PROJECTS ||
|
|
|
|
|
ProjectView == Prj_FILE_BROWSER_PROJECT));
|
2017-09-24 18:51:56 +02:00
|
|
|
|
|
2019-10-14 00:45:46 +02:00
|
|
|
|
/***** Set CSS classes *****/
|
|
|
|
|
ClassLabel = (Prj->Hidden == Prj_HIDDEN) ? "ASG_LABEL_LIGHT" :
|
|
|
|
|
"ASG_LABEL";
|
|
|
|
|
ClassData = (Prj->Hidden == Prj_HIDDEN) ? "DAT_LIGHT" :
|
|
|
|
|
"DAT";
|
|
|
|
|
|
2017-09-24 18:51:56 +02:00
|
|
|
|
/***** Write row with label and text *****/
|
2017-10-06 01:20:05 +02:00
|
|
|
|
switch (ProjectView)
|
|
|
|
|
{
|
|
|
|
|
case Prj_LIST_PROJECTS:
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_Begin ("id=\"%s%u\" style=\"display:none;\"",id,UniqueId);
|
|
|
|
|
HTM_TD_Begin ("colspan=\"4\" class=\"RT %s COLOR%u\"",ClassLabel,Gbl.RowEvenOdd);
|
2017-10-10 18:25:59 +02:00
|
|
|
|
break;
|
2017-10-06 01:20:05 +02:00
|
|
|
|
case Prj_FILE_BROWSER_PROJECT:
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_Begin ("id=\"%s%u\" style=\"display:none;\"",id,UniqueId);
|
|
|
|
|
HTM_TD_Begin ("colspan=\"3\" class=\"RT %s\"",ClassLabel);
|
2017-10-06 01:20:05 +02:00
|
|
|
|
break;
|
2017-10-10 18:25:59 +02:00
|
|
|
|
case Prj_PRINT_ONE_PROJECT:
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_Begin (NULL);
|
|
|
|
|
HTM_TD_Begin ("colspan=\"2\" class=\"RT %s\"",ClassLabel);
|
2017-10-10 18:25:59 +02:00
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
// Not applicable
|
2017-10-06 01:20:05 +02:00
|
|
|
|
break;
|
|
|
|
|
}
|
2019-11-11 10:59:24 +01:00
|
|
|
|
HTM_TxtF ("%s:",Txt_URL);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2019-10-07 20:17:29 +02:00
|
|
|
|
|
2019-10-09 21:05:58 +02:00
|
|
|
|
switch (ProjectView)
|
|
|
|
|
{
|
|
|
|
|
case Prj_LIST_PROJECTS:
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("colspan=\"2\" class=\"LT %s COLOR%u\"",
|
2019-10-14 00:45:46 +02:00
|
|
|
|
ClassData,Gbl.RowEvenOdd);
|
2019-10-09 21:05:58 +02:00
|
|
|
|
break;
|
|
|
|
|
default:
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("colspan=\"2\" class=\"LT %s\"",
|
2019-10-14 00:45:46 +02:00
|
|
|
|
ClassData);
|
2019-10-09 21:05:58 +02:00
|
|
|
|
break;
|
|
|
|
|
}
|
2017-09-24 18:51:56 +02:00
|
|
|
|
if (PutLink)
|
2019-10-28 20:38:29 +01:00
|
|
|
|
HTM_A_Begin ("href=\"%s\" target=\"_blank\"",Prj->URL);
|
2019-11-10 12:36:37 +01:00
|
|
|
|
HTM_Txt (Prj->URL);
|
2017-09-24 18:51:56 +02:00
|
|
|
|
if (PutLink)
|
2019-10-28 13:56:04 +01:00
|
|
|
|
HTM_A_End ();
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2019-10-07 20:17:29 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_End ();
|
2017-09-24 18:51:56 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void Prj_ShowTableAllProjectsURL (const struct Project *Prj)
|
|
|
|
|
{
|
2019-10-14 00:45:46 +02:00
|
|
|
|
const char *ClassData;
|
|
|
|
|
|
|
|
|
|
/***** Set CSS classes *****/
|
|
|
|
|
ClassData = (Prj->Hidden == Prj_HIDDEN) ? "DAT_LIGHT" :
|
|
|
|
|
"DAT";
|
|
|
|
|
|
2017-09-24 18:51:56 +02:00
|
|
|
|
/***** Show URL *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"LT %s COLOR%u\"",ClassData,Gbl.RowEvenOdd);
|
2019-11-10 12:36:37 +01:00
|
|
|
|
HTM_Txt (Prj->URL);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2017-09-24 18:51:56 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-09-20 14:23:08 +02:00
|
|
|
|
/*****************************************************************************/
|
2017-10-01 00:48:36 +02:00
|
|
|
|
/************** Show projects members when showing one project ***************/
|
2017-09-20 14:23:08 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2017-10-01 00:48:36 +02:00
|
|
|
|
static void Prj_ShowOneProjectMembers (struct Project *Prj,
|
|
|
|
|
Prj_ProjectView_t ProjectView)
|
2017-09-20 14:23:08 +02:00
|
|
|
|
{
|
2017-10-01 00:48:36 +02:00
|
|
|
|
unsigned NumRoleToShow;
|
2017-09-20 14:23:08 +02:00
|
|
|
|
|
2017-10-01 00:48:36 +02:00
|
|
|
|
for (NumRoleToShow = 0;
|
|
|
|
|
NumRoleToShow < Brw_NUM_ROLES_TO_SHOW;
|
|
|
|
|
NumRoleToShow++)
|
|
|
|
|
Prj_ShowOneProjectMembersWithARole (Prj,ProjectView,
|
|
|
|
|
Prj_RolesToShow[NumRoleToShow]);
|
2017-09-24 12:31:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-09-19 15:06:19 +02:00
|
|
|
|
/*****************************************************************************/
|
2017-10-01 00:48:36 +02:00
|
|
|
|
/************************* Show users row in a project ***********************/
|
2017-09-19 15:06:19 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2017-10-01 00:48:36 +02:00
|
|
|
|
static void Prj_ShowOneProjectMembersWithARole (const struct Project *Prj,
|
|
|
|
|
Prj_ProjectView_t ProjectView,
|
|
|
|
|
Prj_RoleInProject_t RoleInProject)
|
2017-09-19 15:06:19 +02:00
|
|
|
|
{
|
2017-10-01 11:57:25 +02:00
|
|
|
|
extern const char *Txt_PROJECT_ROLES_SINGUL_Abc[Prj_NUM_ROLES_IN_PROJECT];
|
2017-10-01 00:48:36 +02:00
|
|
|
|
extern const char *Txt_PROJECT_ROLES_PLURAL_Abc[Prj_NUM_ROLES_IN_PROJECT];
|
2017-09-22 00:37:48 +02:00
|
|
|
|
extern const char *Txt_Remove;
|
2019-04-11 23:15:40 +02:00
|
|
|
|
extern const char *Txt_Add_USERS;
|
2019-04-11 09:55:35 +02:00
|
|
|
|
extern const char *Txt_PROJECT_ROLES_PLURAL_abc[Prj_NUM_ROLES_IN_PROJECT];
|
2017-09-19 15:06:19 +02:00
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
2017-10-01 11:57:25 +02:00
|
|
|
|
bool WriteRow;
|
2017-09-19 15:06:19 +02:00
|
|
|
|
unsigned NumUsr;
|
|
|
|
|
unsigned NumUsrs;
|
|
|
|
|
bool ShowPhoto;
|
|
|
|
|
char PhotoURL[PATH_MAX + 1];
|
2019-10-14 00:45:46 +02:00
|
|
|
|
const char *ClassLabel;
|
|
|
|
|
const char *ClassData;
|
2017-10-01 11:57:25 +02:00
|
|
|
|
static const Act_Action_t ActionReqRemUsr[Prj_NUM_ROLES_IN_PROJECT] =
|
2017-09-22 00:56:17 +02:00
|
|
|
|
{
|
2019-11-21 01:27:17 +01:00
|
|
|
|
[Prj_ROLE_UNK] = ActUnk, // Unknown
|
|
|
|
|
[Prj_ROLE_STD] = ActReqRemStdPrj, // Student
|
|
|
|
|
[Prj_ROLE_TUT] = ActReqRemTutPrj, // Tutor
|
|
|
|
|
[Prj_ROLE_EVL] = ActReqRemEvlPrj, // Evaluator
|
2017-09-22 00:56:17 +02:00
|
|
|
|
};
|
2017-10-01 11:57:25 +02:00
|
|
|
|
static const Act_Action_t ActionReqAddUsr[Prj_NUM_ROLES_IN_PROJECT] =
|
2017-09-20 15:02:58 +02:00
|
|
|
|
{
|
2019-11-21 01:27:17 +01:00
|
|
|
|
[Prj_ROLE_UNK] = ActUnk, // Unknown
|
|
|
|
|
[Prj_ROLE_STD] = ActReqAddStdPrj, // Student
|
|
|
|
|
[Prj_ROLE_TUT] = ActReqAddTutPrj, // Tutor
|
|
|
|
|
[Prj_ROLE_EVL] = ActReqAddEvlPrj, // Evaluator
|
2017-09-20 15:02:58 +02:00
|
|
|
|
};
|
2017-09-19 15:06:19 +02:00
|
|
|
|
|
2019-10-14 00:45:46 +02:00
|
|
|
|
/***** Set CSS classes *****/
|
|
|
|
|
ClassLabel = (Prj->Hidden == Prj_HIDDEN) ? "ASG_LABEL_LIGHT" :
|
|
|
|
|
"ASG_LABEL";
|
|
|
|
|
ClassData = (Prj->Hidden == Prj_HIDDEN) ? "DAT_LIGHT" :
|
|
|
|
|
"DAT";
|
|
|
|
|
|
2017-09-19 16:45:42 +02:00
|
|
|
|
/***** Get users in project from database *****/
|
2017-10-01 00:48:36 +02:00
|
|
|
|
NumUsrs = Prj_GetUsrsInPrj (Prj->PrjCod,RoleInProject,&mysql_res);
|
2017-10-01 11:57:25 +02:00
|
|
|
|
WriteRow = (NumUsrs != 0 ||
|
|
|
|
|
ProjectView == Prj_EDIT_ONE_PROJECT);
|
2017-09-19 15:06:19 +02:00
|
|
|
|
|
2017-10-01 11:57:25 +02:00
|
|
|
|
if (WriteRow)
|
2017-10-01 00:48:36 +02:00
|
|
|
|
{
|
2017-10-01 11:57:25 +02:00
|
|
|
|
/***** Start row with label and listing of users *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_Begin (NULL);
|
2017-10-01 00:48:36 +02:00
|
|
|
|
|
2017-10-10 19:17:21 +02:00
|
|
|
|
/* Column for label */
|
2017-10-01 11:57:25 +02:00
|
|
|
|
switch (ProjectView)
|
|
|
|
|
{
|
|
|
|
|
case Prj_LIST_PROJECTS:
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("colspan=\"4\" class=\"RT %s COLOR%u\"",
|
2019-10-14 00:45:46 +02:00
|
|
|
|
ClassLabel,Gbl.RowEvenOdd);
|
2019-11-11 10:59:24 +01:00
|
|
|
|
HTM_TxtF ("%s:",NumUsrs == 1 ? Txt_PROJECT_ROLES_SINGUL_Abc[RoleInProject] :
|
|
|
|
|
Txt_PROJECT_ROLES_PLURAL_Abc[RoleInProject]);
|
2017-10-10 18:25:59 +02:00
|
|
|
|
break;
|
2017-10-06 01:20:05 +02:00
|
|
|
|
case Prj_FILE_BROWSER_PROJECT:
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("colspan=\"3\" class=\"RT %s\"",ClassLabel);
|
2019-11-11 10:59:24 +01:00
|
|
|
|
HTM_TxtF ("%s:",NumUsrs == 1 ? Txt_PROJECT_ROLES_SINGUL_Abc[RoleInProject] :
|
|
|
|
|
Txt_PROJECT_ROLES_PLURAL_Abc[RoleInProject]);
|
2017-10-10 19:17:21 +02:00
|
|
|
|
break;
|
2017-10-01 11:57:25 +02:00
|
|
|
|
case Prj_PRINT_ONE_PROJECT:
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("colspan=\"2\" class=\"RT %s\"",ClassLabel);
|
2019-11-11 10:59:24 +01:00
|
|
|
|
HTM_TxtF ("%s:",NumUsrs == 1 ? Txt_PROJECT_ROLES_SINGUL_Abc[RoleInProject] :
|
|
|
|
|
Txt_PROJECT_ROLES_PLURAL_Abc[RoleInProject]);
|
2017-10-10 19:17:21 +02:00
|
|
|
|
break;
|
|
|
|
|
case Prj_EDIT_ONE_PROJECT:
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"RT ASG_LABEL\"");
|
2019-11-11 10:59:24 +01:00
|
|
|
|
HTM_TxtF ("%s:",Txt_PROJECT_ROLES_PLURAL_Abc[RoleInProject]);
|
2017-10-10 19:17:21 +02:00
|
|
|
|
break;
|
|
|
|
|
}
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2017-10-10 19:17:21 +02:00
|
|
|
|
|
|
|
|
|
/* Start column with list of users */
|
|
|
|
|
switch (ProjectView)
|
|
|
|
|
{
|
|
|
|
|
case Prj_LIST_PROJECTS:
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("colspan=\"2\" class=\"LT %s COLOR%u\"",
|
2019-10-14 00:45:46 +02:00
|
|
|
|
ClassData,Gbl.RowEvenOdd);
|
2017-10-10 19:17:21 +02:00
|
|
|
|
break;
|
|
|
|
|
case Prj_FILE_BROWSER_PROJECT:
|
|
|
|
|
case Prj_PRINT_ONE_PROJECT:
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("colspan=\"2\" class=\"LT %s\"",
|
2019-10-14 00:45:46 +02:00
|
|
|
|
ClassData);
|
2017-10-01 11:57:25 +02:00
|
|
|
|
break;
|
|
|
|
|
case Prj_EDIT_ONE_PROJECT:
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("colspan=\"2\" class=\"LT DAT\"");
|
2017-10-01 11:57:25 +02:00
|
|
|
|
break;
|
|
|
|
|
}
|
2017-09-20 15:02:58 +02:00
|
|
|
|
|
2019-10-20 22:00:28 +02:00
|
|
|
|
/***** Begin table with all members with this role *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TABLE_BeginPadding (2);
|
2017-09-24 13:08:26 +02:00
|
|
|
|
|
2017-10-01 11:57:25 +02:00
|
|
|
|
/***** Write users *****/
|
|
|
|
|
for (NumUsr = 0;
|
|
|
|
|
NumUsr < NumUsrs;
|
|
|
|
|
NumUsr++)
|
2017-09-24 13:08:26 +02:00
|
|
|
|
{
|
2017-10-01 11:57:25 +02:00
|
|
|
|
/* Get user's code */
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
|
|
|
|
Gbl.Usrs.Other.UsrDat.UsrCod = Str_ConvertStrCodToLongCod (row[0]);
|
2017-09-24 13:49:22 +02:00
|
|
|
|
|
2017-10-01 11:57:25 +02:00
|
|
|
|
/* Get user's data */
|
2019-03-19 13:22:14 +01:00
|
|
|
|
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat,Usr_DONT_GET_PREFS))
|
2017-09-24 13:49:22 +02:00
|
|
|
|
{
|
2017-10-01 11:57:25 +02:00
|
|
|
|
/* Start row for this user */
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_Begin (NULL);
|
2017-10-01 11:57:25 +02:00
|
|
|
|
|
|
|
|
|
/* Icon to remove user */
|
|
|
|
|
if (ProjectView == Prj_EDIT_ONE_PROJECT)
|
|
|
|
|
{
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"PRJ_MEMBER_ICO\"");
|
2019-01-12 03:00:59 +01:00
|
|
|
|
Lay_PutContextualLinkOnlyIcon (ActionReqRemUsr[RoleInProject],NULL,
|
|
|
|
|
Prj_PutCurrentParams,
|
|
|
|
|
"trash.svg",
|
|
|
|
|
Txt_Remove);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2017-10-01 11:57:25 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Put user's photo */
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"PRJ_MEMBER_PHO\"");
|
2017-10-01 11:57:25 +02:00
|
|
|
|
ShowPhoto = Pho_ShowingUsrPhotoIsAllowed (&Gbl.Usrs.Other.UsrDat,PhotoURL);
|
|
|
|
|
Pho_ShowUsrPhoto (&Gbl.Usrs.Other.UsrDat,ShowPhoto ? PhotoURL :
|
|
|
|
|
NULL,
|
|
|
|
|
"PHOTO21x28",Pho_ZOOM,false);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2017-09-24 13:49:22 +02:00
|
|
|
|
|
2017-10-01 11:57:25 +02:00
|
|
|
|
/* Write user's name */
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"PRJ_MEMBER_NAM\"");
|
2019-11-10 12:36:37 +01:00
|
|
|
|
HTM_Txt (Gbl.Usrs.Other.UsrDat.FullName);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2017-09-24 13:08:26 +02:00
|
|
|
|
|
2017-10-01 11:57:25 +02:00
|
|
|
|
/* End row for this user */
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_End ();
|
2017-10-01 11:57:25 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2017-09-24 13:49:22 +02:00
|
|
|
|
|
2017-10-01 11:57:25 +02:00
|
|
|
|
/***** Row to add a new user *****/
|
2017-10-10 18:25:59 +02:00
|
|
|
|
switch (ProjectView)
|
2017-10-01 11:57:25 +02:00
|
|
|
|
{
|
2017-10-10 18:25:59 +02:00
|
|
|
|
case Prj_EDIT_ONE_PROJECT:
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_Begin (NULL);
|
|
|
|
|
HTM_TD_Begin ("class=\"PRJ_MEMBER_ICO\"");
|
2017-10-10 18:25:59 +02:00
|
|
|
|
Gbl.Prjs.PrjCod = Prj->PrjCod; // Used to pass project code as a parameter
|
2019-01-10 15:26:33 +01:00
|
|
|
|
Ico_PutContextualIconToAdd (ActionReqAddUsr[RoleInProject],NULL,
|
|
|
|
|
Prj_PutCurrentParams,
|
2019-12-30 21:47:07 +01:00
|
|
|
|
Str_BuildStringStr (Txt_Add_USERS,
|
|
|
|
|
Txt_PROJECT_ROLES_PLURAL_abc[RoleInProject]));
|
|
|
|
|
Str_FreeString ();
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2019-10-07 20:17:29 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"PRJ_MEMBER_PHO\""); // Column for photo
|
|
|
|
|
HTM_TD_End ();
|
2019-10-07 20:17:29 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"PRJ_MEMBER_NAM\""); // Column for name
|
|
|
|
|
HTM_TD_End ();
|
2019-10-07 20:17:29 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_End ();
|
2017-10-10 18:25:59 +02:00
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
2017-09-24 13:49:22 +02:00
|
|
|
|
}
|
2017-09-19 15:06:19 +02:00
|
|
|
|
|
2017-10-01 11:57:25 +02:00
|
|
|
|
/***** End table with all members with this role *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TABLE_End ();
|
2017-10-01 11:57:25 +02:00
|
|
|
|
|
|
|
|
|
/***** End row with label and listing of users *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
HTM_TR_End ();
|
2017-09-20 23:25:55 +02:00
|
|
|
|
}
|
2017-09-20 15:02:58 +02:00
|
|
|
|
|
2017-09-19 15:06:19 +02:00
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-01 00:48:36 +02:00
|
|
|
|
static void Prj_ShowTableAllProjectsMembersWithARole (const struct Project *Prj,
|
|
|
|
|
Prj_RoleInProject_t RoleInProject)
|
2017-09-24 13:08:26 +02:00
|
|
|
|
{
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
|
|
|
|
unsigned NumUsr;
|
|
|
|
|
unsigned NumUsrs;
|
2019-10-14 00:45:46 +02:00
|
|
|
|
const char *ClassData;
|
|
|
|
|
|
|
|
|
|
/***** Set CSS classes *****/
|
|
|
|
|
ClassData = (Prj->Hidden == Prj_HIDDEN) ? "DAT_LIGHT" :
|
|
|
|
|
"DAT";
|
2017-09-24 13:08:26 +02:00
|
|
|
|
|
|
|
|
|
/***** Get users in project from database *****/
|
2017-10-01 00:48:36 +02:00
|
|
|
|
NumUsrs = Prj_GetUsrsInPrj (Prj->PrjCod,RoleInProject,&mysql_res);
|
|
|
|
|
|
|
|
|
|
/***** Start column with list of all members with this role *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"LT %s COLOR%u\"",ClassData,Gbl.RowEvenOdd);
|
2017-09-24 13:08:26 +02:00
|
|
|
|
|
2017-09-24 13:35:19 +02:00
|
|
|
|
if (NumUsrs)
|
2017-09-24 13:08:26 +02:00
|
|
|
|
{
|
2017-10-01 00:48:36 +02:00
|
|
|
|
/***** Write users *****/
|
2019-10-26 12:25:27 +02:00
|
|
|
|
HTM_UL_Begin ("class=\"PRJ_LST_USR\"");
|
2017-09-24 13:08:26 +02:00
|
|
|
|
|
2017-09-24 13:35:19 +02:00
|
|
|
|
for (NumUsr = 0;
|
|
|
|
|
NumUsr < NumUsrs;
|
|
|
|
|
NumUsr++)
|
|
|
|
|
{
|
|
|
|
|
/* Get user's code */
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
|
|
|
|
Gbl.Usrs.Other.UsrDat.UsrCod = Str_ConvertStrCodToLongCod (row[0]);
|
2017-09-24 13:08:26 +02:00
|
|
|
|
|
2017-09-24 13:35:19 +02:00
|
|
|
|
/* Get user's data */
|
2019-03-19 13:22:14 +01:00
|
|
|
|
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat,Usr_DONT_GET_PREFS))
|
2017-10-16 22:24:46 +02:00
|
|
|
|
{
|
|
|
|
|
/* Write user's name in "Surname1 Surname2, FirstName" format */
|
2019-10-26 22:49:13 +02:00
|
|
|
|
HTM_LI_Begin (NULL);
|
2019-11-10 12:36:37 +01:00
|
|
|
|
HTM_Txt (Gbl.Usrs.Other.UsrDat.Surname1);
|
2017-10-16 22:24:46 +02:00
|
|
|
|
if (Gbl.Usrs.Other.UsrDat.Surname2[0])
|
2019-11-11 10:59:24 +01:00
|
|
|
|
HTM_TxtF (" %s",Gbl.Usrs.Other.UsrDat.Surname2);
|
2019-11-11 00:15:44 +01:00
|
|
|
|
HTM_TxtF (", %s",Gbl.Usrs.Other.UsrDat.FirstName);
|
2019-10-26 22:49:13 +02:00
|
|
|
|
HTM_LI_End ();
|
2017-10-16 22:24:46 +02:00
|
|
|
|
}
|
2017-09-24 13:35:19 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-10-26 02:19:42 +02:00
|
|
|
|
HTM_UL_End ();
|
2017-09-24 13:08:26 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
2017-10-01 00:48:36 +02:00
|
|
|
|
|
|
|
|
|
/***** End column with list of all members with this role *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2017-09-24 13:08:26 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2019-10-14 00:45:46 +02:00
|
|
|
|
/*************** Get number of users with a role in a project ****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static unsigned Prj_GetNumUsrsInPrj (long PrjCod,Prj_RoleInProject_t RoleInProject)
|
|
|
|
|
{
|
|
|
|
|
/***** Get users in project from database *****/
|
|
|
|
|
return (unsigned) DB_QueryCOUNT ("can not get number of users in project",
|
|
|
|
|
"SELECT COUNT(UsrCod)"
|
|
|
|
|
" FROM prj_usr"
|
|
|
|
|
" WHERE PrjCod=%ld AND RoleInProject=%u",
|
|
|
|
|
PrjCod,(unsigned) RoleInProject);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*************** Get number of users with a role in a project ****************/
|
2017-09-24 13:08:26 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static unsigned Prj_GetUsrsInPrj (long PrjCod,Prj_RoleInProject_t RoleInProject,
|
|
|
|
|
MYSQL_RES **mysql_res)
|
|
|
|
|
{
|
|
|
|
|
/***** Get users in project from database *****/
|
2018-11-01 19:23:52 +01:00
|
|
|
|
return (unsigned) DB_QuerySELECT (mysql_res,"can not get users in project",
|
2019-10-14 00:45:46 +02:00
|
|
|
|
"SELECT prj_usr.UsrCod," // row[0]
|
|
|
|
|
"usr_data.Surname1 AS S1," // row[1]
|
|
|
|
|
"usr_data.Surname2 AS S2," // row[2]
|
|
|
|
|
"usr_data.FirstName AS FN" // row[3]
|
2018-11-01 19:23:52 +01:00
|
|
|
|
" FROM prj_usr,usr_data"
|
2019-10-14 00:45:46 +02:00
|
|
|
|
" WHERE prj_usr.PrjCod=%ld"
|
|
|
|
|
" AND prj_usr.RoleInProject=%u"
|
2018-11-01 19:23:52 +01:00
|
|
|
|
" AND prj_usr.UsrCod=usr_data.UsrCod"
|
|
|
|
|
" ORDER BY S1,S2,FN",
|
|
|
|
|
PrjCod,(unsigned) RoleInProject);
|
2017-09-24 13:08:26 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-10-07 20:01:34 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************** Get my role in a project *************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2019-04-11 15:24:05 +02:00
|
|
|
|
void Prj_FlushCacheMyRolesInProject (void)
|
2017-10-08 16:12:58 +02:00
|
|
|
|
{
|
2019-04-11 15:24:05 +02:00
|
|
|
|
Gbl.Cache.MyRolesInProject.PrjCod = -1L;
|
|
|
|
|
Gbl.Cache.MyRolesInProject.RolesInProject = 0;
|
2017-10-08 16:12:58 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-04-11 15:24:05 +02:00
|
|
|
|
unsigned Prj_GetMyRolesInProject (long PrjCod)
|
2017-10-07 20:01:34 +02:00
|
|
|
|
{
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
2019-04-11 15:24:05 +02:00
|
|
|
|
unsigned NumRows;
|
|
|
|
|
unsigned NumRow;
|
|
|
|
|
Prj_RoleInProject_t RoleInProject;
|
2017-10-07 20:01:34 +02:00
|
|
|
|
|
2017-10-08 16:12:58 +02:00
|
|
|
|
/***** 1. Fast check: trivial cases *****/
|
|
|
|
|
if (Gbl.Usrs.Me.UsrDat.UsrCod <= 0 ||
|
|
|
|
|
PrjCod <= 0)
|
2019-04-11 15:24:05 +02:00
|
|
|
|
return 0;
|
2017-10-08 16:12:58 +02:00
|
|
|
|
|
|
|
|
|
/***** 2. Fast check: Is my role in project already calculated *****/
|
2019-04-11 15:24:05 +02:00
|
|
|
|
if (PrjCod == Gbl.Cache.MyRolesInProject.PrjCod)
|
|
|
|
|
return Gbl.Cache.MyRolesInProject.RolesInProject;
|
2017-10-08 16:12:58 +02:00
|
|
|
|
|
|
|
|
|
/***** 3. Slow check: Get my role in project from database.
|
|
|
|
|
The result of the query will have one row or none *****/
|
2019-04-11 15:24:05 +02:00
|
|
|
|
Gbl.Cache.MyRolesInProject.PrjCod = PrjCod;
|
|
|
|
|
Gbl.Cache.MyRolesInProject.RolesInProject = 0;
|
|
|
|
|
NumRows = (unsigned) DB_QuerySELECT (&mysql_res,"can not get my roles in project",
|
|
|
|
|
"SELECT RoleInProject FROM prj_usr"
|
|
|
|
|
" WHERE PrjCod=%ld AND UsrCod=%ld",
|
|
|
|
|
PrjCod,Gbl.Usrs.Me.UsrDat.UsrCod);
|
|
|
|
|
for (NumRow = 0;
|
|
|
|
|
NumRow < NumRows;
|
|
|
|
|
NumRow++)
|
2017-10-07 20:01:34 +02:00
|
|
|
|
{
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
2019-04-11 15:24:05 +02:00
|
|
|
|
RoleInProject = Prj_ConvertUnsignedStrToRoleInProject (row[0]);
|
|
|
|
|
if (RoleInProject != Prj_ROLE_UNK)
|
|
|
|
|
Gbl.Cache.MyRolesInProject.RolesInProject |= (1 << RoleInProject);
|
2017-10-07 20:01:34 +02:00
|
|
|
|
}
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
|
2019-04-11 15:24:05 +02:00
|
|
|
|
return Gbl.Cache.MyRolesInProject.RolesInProject;
|
2017-10-08 16:12:58 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************** Get role from unsigned string ************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static Prj_RoleInProject_t Prj_ConvertUnsignedStrToRoleInProject (const char *UnsignedStr)
|
|
|
|
|
{
|
|
|
|
|
unsigned UnsignedNum;
|
|
|
|
|
|
|
|
|
|
if (sscanf (UnsignedStr,"%u",&UnsignedNum) == 1)
|
|
|
|
|
if (UnsignedNum < Prj_NUM_ROLES_IN_PROJECT)
|
|
|
|
|
return (Prj_RoleInProject_t) UnsignedNum;
|
|
|
|
|
|
|
|
|
|
return Prj_ROLE_UNK;
|
2017-10-07 20:01:34 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-09-20 17:12:34 +02:00
|
|
|
|
/*****************************************************************************/
|
2019-04-11 09:55:35 +02:00
|
|
|
|
/******************* Request users to be added to project ********************/
|
2017-09-20 17:12:34 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2019-04-11 09:55:35 +02:00
|
|
|
|
void Prj_ReqAddStds (void)
|
2017-09-20 17:12:34 +02:00
|
|
|
|
{
|
2019-04-11 09:55:35 +02:00
|
|
|
|
Prj_ReqAddUsrs (Prj_ROLE_STD);
|
2017-09-20 17:12:34 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-04-11 09:55:35 +02:00
|
|
|
|
void Prj_ReqAddTuts (void)
|
2017-09-20 17:12:34 +02:00
|
|
|
|
{
|
2019-04-11 09:55:35 +02:00
|
|
|
|
Prj_ReqAddUsrs (Prj_ROLE_TUT);
|
2017-09-20 17:12:34 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-04-11 09:55:35 +02:00
|
|
|
|
void Prj_ReqAddEvls (void)
|
2017-09-20 17:12:34 +02:00
|
|
|
|
{
|
2019-04-11 09:55:35 +02:00
|
|
|
|
Prj_ReqAddUsrs (Prj_ROLE_EVL);
|
2017-09-20 17:12:34 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-04-11 09:55:35 +02:00
|
|
|
|
static void Prj_ReqAddUsrs (Prj_RoleInProject_t RoleInProject)
|
2017-09-20 15:02:58 +02:00
|
|
|
|
{
|
|
|
|
|
extern const char *Hlp_ASSESSMENT_Projects_add_user;
|
2019-04-11 23:15:40 +02:00
|
|
|
|
extern const char *Txt_Add_USERS;
|
2019-04-11 09:55:35 +02:00
|
|
|
|
extern const char *Txt_PROJECT_ROLES_PLURAL_abc[Prj_NUM_ROLES_IN_PROJECT];
|
2017-09-20 17:25:00 +02:00
|
|
|
|
static Act_Action_t ActionAddUsr[Prj_NUM_ROLES_IN_PROJECT] =
|
2017-09-20 15:02:58 +02:00
|
|
|
|
{
|
2019-12-15 20:02:34 +01:00
|
|
|
|
[Prj_ROLE_UNK] = ActUnk, // Unknown
|
|
|
|
|
[Prj_ROLE_STD] = ActAddStdPrj, // Student
|
|
|
|
|
[Prj_ROLE_TUT] = ActAddTutPrj, // Tutor
|
|
|
|
|
[Prj_ROLE_EVL] = ActAddEvlPrj, // Evaluator
|
2017-09-20 15:02:58 +02:00
|
|
|
|
};
|
2019-12-30 22:32:06 +01:00
|
|
|
|
char *TxtButton;
|
2017-09-20 15:02:58 +02:00
|
|
|
|
|
2019-11-15 10:48:20 +01:00
|
|
|
|
/***** Get parameters *****/
|
|
|
|
|
Prj_GetParams ();
|
2017-10-10 01:26:45 +02:00
|
|
|
|
if ((Gbl.Prjs.PrjCod = Prj_GetParamPrjCod ()) == -1L)
|
2017-09-20 17:25:00 +02:00
|
|
|
|
Lay_ShowErrorAndExit ("Code of project is missing.");
|
|
|
|
|
|
2019-04-11 09:55:35 +02:00
|
|
|
|
/***** Put form to select users *****/
|
2019-12-30 22:32:06 +01:00
|
|
|
|
if (asprintf (&TxtButton,Txt_Add_USERS,
|
|
|
|
|
Txt_PROJECT_ROLES_PLURAL_abc[RoleInProject]) < 0)
|
|
|
|
|
Lay_NotEnoughMemoryExit ();
|
2019-11-15 03:34:48 +01:00
|
|
|
|
Usr_PutFormToSelectUsrsToGoToAct (&Prj_MembersToAdd,
|
|
|
|
|
ActionAddUsr[RoleInProject],Prj_PutCurrentParams,
|
2019-04-11 23:15:40 +02:00
|
|
|
|
TxtButton,
|
2019-04-11 09:55:35 +02:00
|
|
|
|
Hlp_ASSESSMENT_Projects_add_user,
|
2019-12-09 11:50:03 +01:00
|
|
|
|
TxtButton,
|
|
|
|
|
false); // Do not put form with date range
|
2019-12-30 22:32:06 +01:00
|
|
|
|
free (TxtButton);
|
2019-04-11 09:55:35 +02:00
|
|
|
|
|
2017-09-21 00:40:09 +02:00
|
|
|
|
/***** Put a form to create/edit project *****/
|
2017-10-10 01:26:45 +02:00
|
|
|
|
Prj_RequestCreatOrEditPrj (Gbl.Prjs.PrjCod);
|
2017-09-20 15:02:58 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2019-04-11 09:55:35 +02:00
|
|
|
|
/******* Get and check list of selected users, and show users' works ********/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Prj_GetSelectedUsrsAndAddStds (void)
|
|
|
|
|
{
|
2019-11-15 03:34:48 +01:00
|
|
|
|
Usr_GetSelectedUsrsAndGoToAct (&Prj_MembersToAdd,
|
|
|
|
|
Prj_AddStds, // when user(s) selected
|
2019-04-11 09:55:35 +02:00
|
|
|
|
Prj_ReqAddStds); // when no user selected
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Prj_GetSelectedUsrsAndAddTuts (void)
|
|
|
|
|
{
|
2019-11-15 03:34:48 +01:00
|
|
|
|
Usr_GetSelectedUsrsAndGoToAct (&Prj_MembersToAdd,
|
|
|
|
|
Prj_AddTuts, // when user(s) selected
|
2019-04-11 09:55:35 +02:00
|
|
|
|
Prj_ReqAddTuts); // when no user selected
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Prj_GetSelectedUsrsAndAddEvls (void)
|
|
|
|
|
{
|
2019-11-15 03:34:48 +01:00
|
|
|
|
Usr_GetSelectedUsrsAndGoToAct (&Prj_MembersToAdd,
|
|
|
|
|
Prj_AddEvls, // when user(s) selected
|
2019-04-11 09:55:35 +02:00
|
|
|
|
Prj_ReqAddEvls); // when no user selected
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/**************************** Add users to project ***************************/
|
2017-09-20 17:12:34 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2019-04-11 09:55:35 +02:00
|
|
|
|
static void Prj_AddStds (void)
|
2017-09-20 17:12:34 +02:00
|
|
|
|
{
|
2019-04-11 09:55:35 +02:00
|
|
|
|
Prj_AddUsrsToProject (Prj_ROLE_STD);
|
2017-09-20 17:12:34 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-04-11 09:55:35 +02:00
|
|
|
|
static void Prj_AddTuts (void)
|
2017-09-20 17:12:34 +02:00
|
|
|
|
{
|
2019-04-11 09:55:35 +02:00
|
|
|
|
Prj_AddUsrsToProject (Prj_ROLE_TUT);
|
2017-09-20 17:12:34 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-04-11 09:55:35 +02:00
|
|
|
|
static void Prj_AddEvls (void)
|
2017-09-20 17:12:34 +02:00
|
|
|
|
{
|
2019-04-11 09:55:35 +02:00
|
|
|
|
Prj_AddUsrsToProject (Prj_ROLE_EVL);
|
2017-09-20 17:12:34 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-04-11 09:55:35 +02:00
|
|
|
|
static void Prj_AddUsrsToProject (Prj_RoleInProject_t RoleInProject)
|
2017-09-20 17:12:34 +02:00
|
|
|
|
{
|
2017-09-23 15:24:22 +02:00
|
|
|
|
extern const char *Txt_THE_USER_X_has_been_enroled_as_a_Y_in_the_project;
|
2019-04-12 10:14:29 +02:00
|
|
|
|
extern const char *Txt_PROJECT_ROLES_SINGUL_abc[Prj_NUM_ROLES_IN_PROJECT][Usr_NUM_SEXS];
|
2017-09-21 01:33:23 +02:00
|
|
|
|
long PrjCod;
|
2019-04-11 09:55:35 +02:00
|
|
|
|
const char *Ptr;
|
2018-10-10 14:03:06 +02:00
|
|
|
|
bool ItsMe;
|
2017-09-21 01:33:23 +02:00
|
|
|
|
|
2017-09-20 23:25:55 +02:00
|
|
|
|
/***** Get project code *****/
|
2017-09-21 01:33:23 +02:00
|
|
|
|
if ((PrjCod = Prj_GetParamPrjCod ()) == -1L)
|
2017-09-20 23:25:55 +02:00
|
|
|
|
Lay_ShowErrorAndExit ("Code of project is missing.");
|
|
|
|
|
|
2019-04-11 09:55:35 +02:00
|
|
|
|
/***** Add the selected users to project *****/
|
2019-11-15 10:48:20 +01:00
|
|
|
|
Ptr = Prj_MembersToAdd.List[Rol_UNK];
|
2019-04-11 09:55:35 +02:00
|
|
|
|
while (*Ptr)
|
2017-09-21 01:33:23 +02:00
|
|
|
|
{
|
2019-04-11 09:55:35 +02:00
|
|
|
|
/* Get next user */
|
|
|
|
|
Par_GetNextStrUntilSeparParamMult (&Ptr,Gbl.Usrs.Other.UsrDat.EncryptedUsrCod,
|
|
|
|
|
Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64);
|
|
|
|
|
Usr_GetUsrCodFromEncryptedUsrCod (&Gbl.Usrs.Other.UsrDat);
|
2017-09-21 01:33:23 +02:00
|
|
|
|
|
2019-04-11 09:55:35 +02:00
|
|
|
|
/* Get user's data */
|
2019-11-25 23:18:08 +01:00
|
|
|
|
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat,Usr_DONT_GET_PREFS))
|
2019-04-11 09:55:35 +02:00
|
|
|
|
{
|
2017-09-25 00:22:54 +02:00
|
|
|
|
/* Add user to project */
|
2018-11-02 16:39:35 +01:00
|
|
|
|
DB_QueryREPLACE ("can not add user to project",
|
|
|
|
|
"REPLACE INTO prj_usr"
|
|
|
|
|
" (PrjCod,RoleInProject,UsrCod)"
|
|
|
|
|
" VALUES"
|
|
|
|
|
" (%ld,%u,%ld)",
|
2019-04-11 09:55:35 +02:00
|
|
|
|
PrjCod,(unsigned) RoleInProject,
|
|
|
|
|
Gbl.Usrs.Other.UsrDat.UsrCod);
|
2017-09-25 00:22:54 +02:00
|
|
|
|
|
2019-04-11 09:55:35 +02:00
|
|
|
|
/* Flush cache */
|
2018-10-10 23:56:42 +02:00
|
|
|
|
ItsMe = Usr_ItsMe (Gbl.Usrs.Other.UsrDat.UsrCod);
|
2018-10-10 14:03:06 +02:00
|
|
|
|
if (ItsMe)
|
2019-04-11 15:24:05 +02:00
|
|
|
|
Prj_FlushCacheMyRolesInProject ();
|
2017-10-08 16:12:58 +02:00
|
|
|
|
|
2017-09-25 00:22:54 +02:00
|
|
|
|
/* Show success alert */
|
2019-02-16 18:25:41 +01:00
|
|
|
|
Ale_ShowAlert (Ale_SUCCESS,Txt_THE_USER_X_has_been_enroled_as_a_Y_in_the_project,
|
2019-04-11 09:55:35 +02:00
|
|
|
|
Gbl.Usrs.Other.UsrDat.FullName,
|
2019-04-12 10:14:29 +02:00
|
|
|
|
Txt_PROJECT_ROLES_SINGUL_abc[RoleInProject][Gbl.Usrs.Other.UsrDat.Sex]);
|
2019-04-11 09:55:35 +02:00
|
|
|
|
}
|
2017-09-21 01:33:23 +02:00
|
|
|
|
}
|
2019-04-11 09:55:35 +02:00
|
|
|
|
|
2019-11-15 10:48:20 +01:00
|
|
|
|
/***** Free memory used by lists of selected encrypted users' codes *****/
|
|
|
|
|
Usr_FreeListsSelectedEncryptedUsrsCods (&Prj_MembersToAdd);
|
|
|
|
|
|
2017-09-21 01:33:23 +02:00
|
|
|
|
/***** Put form to edit project again *****/
|
|
|
|
|
Prj_RequestCreatOrEditPrj (PrjCod);
|
2017-09-20 17:12:34 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-09-22 00:56:17 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************ Request confirmation to remove user from project ***************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Prj_ReqRemStd (void)
|
|
|
|
|
{
|
2017-09-22 14:12:05 +02:00
|
|
|
|
Prj_ReqRemUsrFromPrj (Prj_ROLE_STD);
|
2017-09-22 00:56:17 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Prj_ReqRemTut (void)
|
|
|
|
|
{
|
2017-09-22 14:12:05 +02:00
|
|
|
|
Prj_ReqRemUsrFromPrj (Prj_ROLE_TUT);
|
2017-09-22 00:56:17 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-04-11 09:55:35 +02:00
|
|
|
|
void Prj_ReqRemEvl (void)
|
2017-09-22 00:56:17 +02:00
|
|
|
|
{
|
2019-04-11 09:55:35 +02:00
|
|
|
|
Prj_ReqRemUsrFromPrj (Prj_ROLE_EVL);
|
2017-09-22 00:56:17 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void Prj_ReqRemUsrFromPrj (Prj_RoleInProject_t RoleInProject)
|
|
|
|
|
{
|
2017-09-23 15:24:22 +02:00
|
|
|
|
extern const char *Txt_Do_you_really_want_to_be_removed_as_a_X_from_the_project_Y;
|
|
|
|
|
extern const char *Txt_Do_you_really_want_to_remove_the_following_user_as_a_X_from_the_project_Y;
|
2019-04-12 10:14:29 +02:00
|
|
|
|
extern const char *Txt_PROJECT_ROLES_SINGUL_abc[Prj_NUM_ROLES_IN_PROJECT][Usr_NUM_SEXS];
|
|
|
|
|
extern const char *Txt_Remove_USER_from_this_project;
|
2017-09-22 00:56:17 +02:00
|
|
|
|
static Act_Action_t ActionRemUsr[Prj_NUM_ROLES_IN_PROJECT] =
|
|
|
|
|
{
|
2019-12-15 20:02:34 +01:00
|
|
|
|
[Prj_ROLE_UNK] = ActUnk, // Unknown
|
|
|
|
|
[Prj_ROLE_STD] = ActRemStdPrj, // Student
|
|
|
|
|
[Prj_ROLE_TUT] = ActRemTutPrj, // Tutor
|
|
|
|
|
[Prj_ROLE_EVL] = ActRemEvlPrj, // Evaluator
|
2017-09-22 00:56:17 +02:00
|
|
|
|
};
|
2017-09-23 15:24:22 +02:00
|
|
|
|
struct Project Prj;
|
2017-09-22 14:12:05 +02:00
|
|
|
|
bool ItsMe;
|
|
|
|
|
|
2017-09-23 15:24:22 +02:00
|
|
|
|
/***** Allocate memory for the project *****/
|
|
|
|
|
Prj_AllocMemProject (&Prj);
|
|
|
|
|
|
|
|
|
|
/***** Get parameters *****/
|
2017-10-10 01:26:45 +02:00
|
|
|
|
Prj_GetParams ();
|
2017-10-07 18:11:49 +02:00
|
|
|
|
if ((Prj.PrjCod = Prj_GetParamPrjCod ()) < 0)
|
2017-09-23 15:24:22 +02:00
|
|
|
|
Lay_ShowErrorAndExit ("Code of project is missing.");
|
|
|
|
|
|
|
|
|
|
/***** Get data of the project from database *****/
|
|
|
|
|
Prj_GetDataOfProjectByCod (&Prj);
|
|
|
|
|
|
2017-09-22 14:12:05 +02:00
|
|
|
|
/***** Get user to be removed *****/
|
|
|
|
|
if (Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ())
|
|
|
|
|
{
|
2019-04-18 11:10:39 +02:00
|
|
|
|
if (Prj_CheckIfICanEditProject (&Prj))
|
2017-09-22 14:12:05 +02:00
|
|
|
|
{
|
2018-10-10 23:56:42 +02:00
|
|
|
|
ItsMe = Usr_ItsMe (Gbl.Usrs.Other.UsrDat.UsrCod);
|
2017-09-22 14:12:05 +02:00
|
|
|
|
|
2019-04-12 10:14:29 +02:00
|
|
|
|
/***** Show question and button to remove user as a role from project *****/
|
2017-09-22 14:12:05 +02:00
|
|
|
|
/* Start alert */
|
2019-02-17 01:14:55 +01:00
|
|
|
|
Ale_ShowAlertAndButton1 (Ale_QUESTION,ItsMe ? Txt_Do_you_really_want_to_be_removed_as_a_X_from_the_project_Y :
|
|
|
|
|
Txt_Do_you_really_want_to_remove_the_following_user_as_a_X_from_the_project_Y,
|
2019-04-12 10:14:29 +02:00
|
|
|
|
Txt_PROJECT_ROLES_SINGUL_abc[RoleInProject][Gbl.Usrs.Other.UsrDat.Sex],
|
2019-02-17 01:14:55 +01:00
|
|
|
|
Prj.Title);
|
2017-09-22 14:12:05 +02:00
|
|
|
|
|
|
|
|
|
/* Show user's record */
|
|
|
|
|
Rec_ShowSharedRecordUnmodifiable (&Gbl.Usrs.Other.UsrDat);
|
|
|
|
|
|
|
|
|
|
/* Show form to request confirmation */
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_StartForm (ActionRemUsr[RoleInProject]);
|
2017-10-10 01:26:45 +02:00
|
|
|
|
Gbl.Prjs.PrjCod = Prj.PrjCod;
|
|
|
|
|
Prj_PutCurrentParams ();
|
2019-12-30 21:47:07 +01:00
|
|
|
|
Btn_PutRemoveButton (Str_BuildStringStr (Txt_Remove_USER_from_this_project,
|
|
|
|
|
Txt_PROJECT_ROLES_SINGUL_abc[RoleInProject][Gbl.Usrs.Other.UsrDat.Sex]));
|
|
|
|
|
Str_FreeString ();
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_EndForm ();
|
2017-09-22 14:12:05 +02:00
|
|
|
|
|
|
|
|
|
/* End alert */
|
|
|
|
|
Ale_ShowAlertAndButton2 (ActUnk,NULL,NULL,NULL,Btn_NO_BUTTON,NULL);
|
|
|
|
|
}
|
|
|
|
|
else
|
2019-03-09 20:12:44 +01:00
|
|
|
|
Ale_ShowAlertUserNotFoundOrYouDoNotHavePermission ();
|
2017-09-22 14:12:05 +02:00
|
|
|
|
}
|
|
|
|
|
else
|
2019-03-09 20:12:44 +01:00
|
|
|
|
Ale_ShowAlertUserNotFoundOrYouDoNotHavePermission ();
|
2017-09-22 14:12:05 +02:00
|
|
|
|
|
2017-09-23 15:24:22 +02:00
|
|
|
|
/***** Free memory of the project *****/
|
|
|
|
|
Prj_FreeMemProject (&Prj);
|
2017-09-22 14:12:05 +02:00
|
|
|
|
|
2017-09-23 15:24:22 +02:00
|
|
|
|
/***** Put form to edit project again *****/
|
|
|
|
|
Prj_RequestCreatOrEditPrj (Prj.PrjCod);
|
2017-09-22 00:56:17 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************ Remove user from project ***************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Prj_RemStd (void)
|
|
|
|
|
{
|
2017-09-23 15:24:22 +02:00
|
|
|
|
Prj_RemUsrFromPrj (Prj_ROLE_STD);
|
2017-09-22 00:56:17 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Prj_RemTut (void)
|
|
|
|
|
{
|
2017-09-23 15:24:22 +02:00
|
|
|
|
Prj_RemUsrFromPrj (Prj_ROLE_TUT);
|
2017-09-22 00:56:17 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-04-11 09:55:35 +02:00
|
|
|
|
void Prj_RemEvl (void)
|
2017-09-22 00:56:17 +02:00
|
|
|
|
{
|
2019-04-11 09:55:35 +02:00
|
|
|
|
Prj_RemUsrFromPrj (Prj_ROLE_EVL);
|
2017-09-23 15:24:22 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void Prj_RemUsrFromPrj (Prj_RoleInProject_t RoleInProject)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_THE_USER_X_has_been_removed_as_a_Y_from_the_project_Z;
|
2019-04-12 10:14:29 +02:00
|
|
|
|
extern const char *Txt_PROJECT_ROLES_SINGUL_abc[Prj_NUM_ROLES_IN_PROJECT][Usr_NUM_SEXS];
|
2017-09-23 15:24:22 +02:00
|
|
|
|
struct Project Prj;
|
2018-10-10 14:03:06 +02:00
|
|
|
|
bool ItsMe;
|
2017-09-23 15:24:22 +02:00
|
|
|
|
|
|
|
|
|
/***** Allocate memory for the project *****/
|
|
|
|
|
Prj_AllocMemProject (&Prj);
|
|
|
|
|
|
|
|
|
|
/***** Get parameters *****/
|
2017-10-10 01:26:45 +02:00
|
|
|
|
Prj_GetParams ();
|
2017-10-07 18:11:49 +02:00
|
|
|
|
if ((Prj.PrjCod = Prj_GetParamPrjCod ()) < 0)
|
2017-09-23 15:24:22 +02:00
|
|
|
|
Lay_ShowErrorAndExit ("Code of project is missing.");
|
|
|
|
|
|
|
|
|
|
/***** Get data of the project from database *****/
|
|
|
|
|
Prj_GetDataOfProjectByCod (&Prj);
|
|
|
|
|
|
|
|
|
|
/***** Get user to be removed *****/
|
|
|
|
|
if (Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ())
|
|
|
|
|
{
|
2019-04-18 11:10:39 +02:00
|
|
|
|
if (Prj_CheckIfICanEditProject (&Prj))
|
2017-09-23 15:24:22 +02:00
|
|
|
|
{
|
|
|
|
|
/***** Remove user from the table of project-users *****/
|
2018-11-02 22:00:31 +01:00
|
|
|
|
DB_QueryDELETE ("can not remove a user from a project",
|
|
|
|
|
"DELETE FROM prj_usr"
|
|
|
|
|
" WHERE PrjCod=%ld AND RoleInProject=%u"
|
|
|
|
|
" AND UsrCod=%ld",
|
|
|
|
|
Prj.PrjCod,
|
|
|
|
|
(unsigned) RoleInProject,
|
|
|
|
|
Gbl.Usrs.Other.UsrDat.UsrCod);
|
2017-09-23 15:24:22 +02:00
|
|
|
|
|
2017-10-08 16:12:58 +02:00
|
|
|
|
/***** Flush cache *****/
|
2018-10-10 23:56:42 +02:00
|
|
|
|
ItsMe = Usr_ItsMe (Gbl.Usrs.Other.UsrDat.UsrCod);
|
2018-10-10 14:03:06 +02:00
|
|
|
|
if (ItsMe)
|
2019-04-11 15:24:05 +02:00
|
|
|
|
Prj_FlushCacheMyRolesInProject ();
|
2017-10-08 16:12:58 +02:00
|
|
|
|
|
2017-09-23 15:24:22 +02:00
|
|
|
|
/***** Show success alert *****/
|
2019-02-16 18:25:41 +01:00
|
|
|
|
Ale_ShowAlert (Ale_SUCCESS,Txt_THE_USER_X_has_been_removed_as_a_Y_from_the_project_Z,
|
|
|
|
|
Gbl.Usrs.Other.UsrDat.FullName,
|
2019-04-12 10:14:29 +02:00
|
|
|
|
Txt_PROJECT_ROLES_SINGUL_abc[RoleInProject][Gbl.Usrs.Other.UsrDat.Sex],
|
2019-02-16 18:25:41 +01:00
|
|
|
|
Prj.Title);
|
2017-09-23 15:24:22 +02:00
|
|
|
|
}
|
|
|
|
|
else
|
2019-03-09 20:12:44 +01:00
|
|
|
|
Ale_ShowAlertUserNotFoundOrYouDoNotHavePermission ();
|
2017-09-23 15:24:22 +02:00
|
|
|
|
}
|
|
|
|
|
else
|
2019-03-09 20:12:44 +01:00
|
|
|
|
Ale_ShowAlertUserNotFoundOrYouDoNotHavePermission ();
|
2017-09-23 15:24:22 +02:00
|
|
|
|
|
|
|
|
|
/***** Free memory of the project *****/
|
|
|
|
|
Prj_FreeMemProject (&Prj);
|
|
|
|
|
|
|
|
|
|
/***** Put form to edit project again *****/
|
|
|
|
|
Prj_RequestCreatOrEditPrj (Prj.PrjCod);
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-20 17:12:34 +02:00
|
|
|
|
/*****************************************************************************/
|
2017-09-17 16:58:09 +02:00
|
|
|
|
/********* Get parameter with the type or order in list of projects **********/
|
2017-09-15 13:19:27 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2017-09-17 16:58:09 +02:00
|
|
|
|
static void Prj_GetParamPrjOrder (void)
|
2017-09-15 13:19:27 +02:00
|
|
|
|
{
|
2017-09-23 21:15:17 +02:00
|
|
|
|
Gbl.Prjs.SelectedOrder = (Prj_Order_t)
|
2017-09-15 13:19:27 +02:00
|
|
|
|
Par_GetParToUnsignedLong ("Order",
|
|
|
|
|
0,
|
2017-09-23 21:15:17 +02:00
|
|
|
|
Prj_NUM_ORDERS - 1,
|
2017-09-15 13:19:27 +02:00
|
|
|
|
(unsigned long) Prj_ORDER_DEFAULT);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2017-09-17 16:58:09 +02:00
|
|
|
|
/***** Put a hidden parameter with the type of order in list of projects *****/
|
2017-09-15 13:19:27 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Prj_PutHiddenParamPrjOrder (void)
|
|
|
|
|
{
|
2019-11-03 13:19:32 +01:00
|
|
|
|
Par_PutHiddenParamUnsigned (NULL,"Order",(unsigned) Gbl.Prjs.SelectedOrder);
|
2017-09-15 13:19:27 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2017-09-17 16:58:09 +02:00
|
|
|
|
/****************** Put a link (form) to edit one project ********************/
|
2017-09-15 13:19:27 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2019-04-17 12:40:04 +02:00
|
|
|
|
static void Prj_PutFormsToRemEditOnePrj (const struct Project *Prj,
|
2019-04-20 13:37:01 +02:00
|
|
|
|
const char *Anchor,
|
2017-10-08 16:12:58 +02:00
|
|
|
|
bool ICanViewProjectFiles)
|
2017-09-15 13:19:27 +02:00
|
|
|
|
{
|
2019-04-17 12:40:04 +02:00
|
|
|
|
Gbl.Prjs.PrjCod = Prj->PrjCod; // Used as parameter in contextual links
|
2017-09-15 13:19:27 +02:00
|
|
|
|
|
2019-04-18 11:10:39 +02:00
|
|
|
|
if (Prj_CheckIfICanEditProject (Prj))
|
2017-09-24 18:51:56 +02:00
|
|
|
|
{
|
|
|
|
|
/***** Put form to remove project *****/
|
2017-10-10 01:26:45 +02:00
|
|
|
|
Ico_PutContextualIconToRemove (ActReqRemPrj,Prj_PutCurrentParams);
|
2017-09-24 18:51:56 +02:00
|
|
|
|
|
|
|
|
|
/***** Put form to hide/show project *****/
|
2019-04-17 12:40:04 +02:00
|
|
|
|
switch (Prj->Hidden)
|
2017-10-10 01:26:45 +02:00
|
|
|
|
{
|
|
|
|
|
case Prj_HIDDEN:
|
2019-04-20 13:37:01 +02:00
|
|
|
|
Ico_PutContextualIconToUnhide (ActShoPrj,Anchor,Prj_PutCurrentParams);
|
2017-10-10 01:26:45 +02:00
|
|
|
|
break;
|
|
|
|
|
case Prj_VISIBL:
|
2019-04-20 13:37:01 +02:00
|
|
|
|
Ico_PutContextualIconToHide (ActHidPrj,Anchor,Prj_PutCurrentParams);
|
2017-10-10 01:26:45 +02:00
|
|
|
|
break;
|
|
|
|
|
}
|
2017-09-24 18:51:56 +02:00
|
|
|
|
|
|
|
|
|
/***** Put form to edit project *****/
|
2017-10-10 01:26:45 +02:00
|
|
|
|
Ico_PutContextualIconToEdit (ActEdiOnePrj,Prj_PutCurrentParams);
|
2017-09-24 18:51:56 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-10-07 18:47:46 +02:00
|
|
|
|
/***** Put form to admin project documents *****/
|
2017-10-08 16:12:58 +02:00
|
|
|
|
if (ICanViewProjectFiles)
|
2017-10-10 01:26:45 +02:00
|
|
|
|
Ico_PutContextualIconToViewFiles (ActAdmDocPrj,Prj_PutCurrentParams);
|
2017-10-07 18:47:46 +02:00
|
|
|
|
|
2017-09-24 18:51:56 +02:00
|
|
|
|
/***** Put form to print project *****/
|
2017-10-10 01:26:45 +02:00
|
|
|
|
Ico_PutContextualIconToPrint (ActPrnOnePrj,Prj_PutCurrentParams);
|
2019-04-17 12:40:04 +02:00
|
|
|
|
|
2019-04-18 11:00:28 +02:00
|
|
|
|
/***** Locked/unlocked project edition *****/
|
2019-10-25 22:48:34 +02:00
|
|
|
|
if (Prj_CheckIfICanConfigAllProjects ())
|
2019-04-17 22:06:23 +02:00
|
|
|
|
{
|
2019-04-18 11:00:28 +02:00
|
|
|
|
/* Put form to lock/unlock project edition */
|
2019-10-24 00:04:40 +02:00
|
|
|
|
HTM_DIV_Begin ("id=\"prj_lck_%ld\"",Prj->PrjCod);
|
2019-04-17 22:06:23 +02:00
|
|
|
|
Prj_FormLockUnlock (Prj);
|
2019-10-23 20:07:56 +02:00
|
|
|
|
HTM_DIV_End ();
|
2019-04-17 22:06:23 +02:00
|
|
|
|
}
|
2019-04-18 11:00:28 +02:00
|
|
|
|
else
|
|
|
|
|
/* Put icon toinform about locked/unlocked project edition */
|
|
|
|
|
Prj_PutIconOffLockedUnlocked (Prj);
|
2017-09-24 18:51:56 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-10-07 18:47:46 +02:00
|
|
|
|
/*****************************************************************************/
|
2017-10-08 16:12:58 +02:00
|
|
|
|
/******************** Can I view files of a given project? *******************/
|
2017-10-07 18:47:46 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2019-04-11 15:24:05 +02:00
|
|
|
|
bool Prj_CheckIfICanViewProjectFiles (unsigned MyRolesInProject)
|
2017-10-07 18:47:46 +02:00
|
|
|
|
{
|
|
|
|
|
switch (Gbl.Usrs.Me.Role.Logged)
|
|
|
|
|
{
|
|
|
|
|
case Rol_STD:
|
|
|
|
|
case Rol_NET:
|
|
|
|
|
case Rol_TCH:
|
2019-04-11 15:24:05 +02:00
|
|
|
|
return (MyRolesInProject != 0); // Am I a member?
|
2017-10-07 18:47:46 +02:00
|
|
|
|
case Rol_SYS_ADM:
|
|
|
|
|
return true;
|
|
|
|
|
default:
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-24 18:51:56 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************ Can I edit a given project? ************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2019-04-18 11:10:39 +02:00
|
|
|
|
static bool Prj_CheckIfICanEditProject (const struct Project *Prj)
|
2017-09-24 18:51:56 +02:00
|
|
|
|
{
|
2017-09-15 13:19:27 +02:00
|
|
|
|
switch (Gbl.Usrs.Me.Role.Logged)
|
|
|
|
|
{
|
2017-09-24 18:51:56 +02:00
|
|
|
|
case Rol_NET:
|
2019-04-18 11:10:39 +02:00
|
|
|
|
if (Prj->Locked == Prj_LOCKED) // Locked edition
|
|
|
|
|
return false;
|
|
|
|
|
return (Prj_GetMyRolesInProject (Prj->PrjCod) &
|
|
|
|
|
(1 << Prj_ROLE_TUT)) != 0; // Am I a tutor?
|
2017-09-15 13:19:27 +02:00
|
|
|
|
case Rol_TCH:
|
|
|
|
|
case Rol_SYS_ADM:
|
2017-09-24 18:51:56 +02:00
|
|
|
|
return true;
|
2017-09-15 13:19:27 +02:00
|
|
|
|
default:
|
2017-09-24 18:51:56 +02:00
|
|
|
|
return false;
|
2017-09-15 13:19:27 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2017-09-17 16:58:09 +02:00
|
|
|
|
/************************** List all the projects ****************************/
|
2017-09-15 13:19:27 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2019-11-13 09:49:52 +01:00
|
|
|
|
static void Prj_GetListProjects (void)
|
2017-09-15 13:19:27 +02:00
|
|
|
|
{
|
2019-01-03 15:25:18 +01:00
|
|
|
|
char *PreNonSubQuery;
|
|
|
|
|
char *HidVisSubQuery;
|
|
|
|
|
char *DptCodSubQuery;
|
|
|
|
|
static const char *OrderBySubQuery[Prj_NUM_ORDERS] =
|
|
|
|
|
{
|
2019-11-21 01:27:17 +01:00
|
|
|
|
[Prj_ORDER_START_TIME] = "projects.CreatTime DESC,"
|
|
|
|
|
"projects.ModifTime DESC,"
|
|
|
|
|
"projects.Title",
|
|
|
|
|
[Prj_ORDER_END_TIME ] = "projects.ModifTime DESC,"
|
|
|
|
|
"projects.CreatTime DESC,"
|
|
|
|
|
"projects.Title",
|
|
|
|
|
[Prj_ORDER_TITLE ] = "projects.Title,"
|
|
|
|
|
"projects.CreatTime DESC,"
|
|
|
|
|
"projects.ModifTime DESC",
|
|
|
|
|
[Prj_ORDER_DEPARTMENT] = "departments.FullName,"
|
|
|
|
|
"projects.CreatTime DESC,"
|
|
|
|
|
"projects.ModifTime DESC,"
|
|
|
|
|
"projects.Title",
|
2019-01-03 15:25:18 +01:00
|
|
|
|
};
|
2019-11-14 02:29:18 +01:00
|
|
|
|
MYSQL_RES *mysql_res = NULL; // Initialized to avoid freeing when not assigned
|
2017-09-15 13:19:27 +02:00
|
|
|
|
MYSQL_ROW row;
|
2019-11-13 09:49:52 +01:00
|
|
|
|
unsigned NumUsrsInList;
|
|
|
|
|
long *LstSelectedUsrCods;
|
2019-11-14 02:29:18 +01:00
|
|
|
|
char *SubQueryUsrs;
|
2018-11-01 19:23:52 +01:00
|
|
|
|
unsigned long NumRows = 0; // Initialized to avoid warning
|
2019-10-17 00:18:31 +02:00
|
|
|
|
unsigned NumPrjsFromDB;
|
|
|
|
|
unsigned NumPrjsAfterFilter = 0;
|
2017-09-17 16:58:09 +02:00
|
|
|
|
unsigned NumPrj;
|
2019-10-17 00:18:31 +02:00
|
|
|
|
struct Prj_Faults Faults;
|
|
|
|
|
long PrjCod;
|
2017-09-15 13:19:27 +02:00
|
|
|
|
|
2019-11-13 09:49:52 +01:00
|
|
|
|
/***** Get list of projects from database *****/
|
2017-09-17 16:58:09 +02:00
|
|
|
|
if (Gbl.Prjs.LstIsRead)
|
2017-09-15 13:19:27 +02:00
|
|
|
|
Prj_FreeListProjects ();
|
|
|
|
|
|
2019-10-25 01:15:11 +02:00
|
|
|
|
if (Gbl.Prjs.Filter.Assign && // Any selector is on
|
|
|
|
|
Gbl.Prjs.Filter.Hidden && // Any selector is on
|
2019-10-17 00:18:31 +02:00
|
|
|
|
Gbl.Prjs.Filter.Faulti) // Any selector is on
|
2017-09-15 13:19:27 +02:00
|
|
|
|
{
|
2019-10-25 22:48:34 +02:00
|
|
|
|
/* Assigned subquery */
|
2019-10-25 01:15:11 +02:00
|
|
|
|
switch (Gbl.Prjs.Filter.Assign)
|
2017-10-10 01:26:45 +02:00
|
|
|
|
{
|
2019-10-25 22:48:34 +02:00
|
|
|
|
case (1 << Prj_ASSIGNED): // Assigned projects
|
|
|
|
|
if (asprintf (&PreNonSubQuery," AND projects.Assigned='Y'") < 0)
|
2019-01-03 15:25:18 +01:00
|
|
|
|
Lay_NotEnoughMemoryExit ();
|
2017-10-10 01:26:45 +02:00
|
|
|
|
break;
|
2019-10-25 22:48:34 +02:00
|
|
|
|
case (1 << Prj_NONASSIG): // Non-assigned projects
|
|
|
|
|
if (asprintf (&PreNonSubQuery," AND projects.Assigned='N'") < 0)
|
2019-01-03 15:25:18 +01:00
|
|
|
|
Lay_NotEnoughMemoryExit ();
|
2017-10-10 01:26:45 +02:00
|
|
|
|
break;
|
2019-01-03 15:25:18 +01:00
|
|
|
|
default: // All projects
|
|
|
|
|
if (asprintf (&PreNonSubQuery,"%s","") < 0)
|
|
|
|
|
Lay_NotEnoughMemoryExit ();
|
2017-10-10 01:26:45 +02:00
|
|
|
|
break;
|
|
|
|
|
}
|
2017-09-23 21:15:17 +02:00
|
|
|
|
|
2017-10-10 01:26:45 +02:00
|
|
|
|
/* Hidden subquery */
|
|
|
|
|
switch (Gbl.Usrs.Me.Role.Logged)
|
2017-09-29 18:23:31 +02:00
|
|
|
|
{
|
2017-10-10 01:26:45 +02:00
|
|
|
|
case Rol_STD: // Students can view only visible projects
|
2019-01-03 15:25:18 +01:00
|
|
|
|
if (asprintf (&HidVisSubQuery," AND projects.Hidden='N'") < 0)
|
|
|
|
|
Lay_NotEnoughMemoryExit ();
|
2017-09-29 18:23:31 +02:00
|
|
|
|
break;
|
2017-10-10 01:26:45 +02:00
|
|
|
|
case Rol_NET:
|
|
|
|
|
case Rol_TCH:
|
|
|
|
|
case Rol_SYS_ADM:
|
2019-10-25 01:15:11 +02:00
|
|
|
|
switch (Gbl.Prjs.Filter.Hidden)
|
2017-10-10 01:26:45 +02:00
|
|
|
|
{
|
2019-01-03 15:25:18 +01:00
|
|
|
|
case (1 << Prj_HIDDEN): // Hidden projects
|
|
|
|
|
if (asprintf (&HidVisSubQuery," AND projects.Hidden='Y'") < 0)
|
|
|
|
|
Lay_NotEnoughMemoryExit ();
|
2017-10-10 01:26:45 +02:00
|
|
|
|
break;
|
2019-01-03 15:25:18 +01:00
|
|
|
|
case (1 << Prj_VISIBL): // Visible projects
|
|
|
|
|
if (asprintf (&HidVisSubQuery," AND projects.Hidden='N'") < 0)
|
|
|
|
|
Lay_NotEnoughMemoryExit ();
|
2017-10-10 01:26:45 +02:00
|
|
|
|
break;
|
2019-01-03 15:25:18 +01:00
|
|
|
|
default: // All projects
|
|
|
|
|
if (asprintf (&HidVisSubQuery,"%s","") < 0)
|
|
|
|
|
Lay_NotEnoughMemoryExit ();
|
2017-10-10 01:26:45 +02:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
2019-09-28 15:03:22 +02:00
|
|
|
|
Rol_WrongRoleExit ();
|
2017-09-29 18:23:31 +02:00
|
|
|
|
break;
|
|
|
|
|
}
|
2017-10-10 01:26:45 +02:00
|
|
|
|
|
2017-10-10 12:37:09 +02:00
|
|
|
|
/* Department subquery */
|
|
|
|
|
if (Gbl.Prjs.Filter.DptCod >= 0)
|
2019-01-03 15:25:18 +01:00
|
|
|
|
{
|
|
|
|
|
if (asprintf (&DptCodSubQuery," AND projects.DptCod=%ld",
|
|
|
|
|
Gbl.Prjs.Filter.DptCod) < 0)
|
|
|
|
|
Lay_NotEnoughMemoryExit ();
|
|
|
|
|
}
|
2017-10-10 12:37:09 +02:00
|
|
|
|
else // Any department
|
2017-09-29 18:23:31 +02:00
|
|
|
|
{
|
2019-01-03 15:25:18 +01:00
|
|
|
|
if (asprintf (&DptCodSubQuery,"%s","") < 0)
|
|
|
|
|
Lay_NotEnoughMemoryExit ();
|
2017-09-29 18:23:31 +02:00
|
|
|
|
}
|
2017-09-23 21:15:17 +02:00
|
|
|
|
|
2017-10-10 01:26:45 +02:00
|
|
|
|
/* Query */
|
2019-11-11 15:46:54 +01:00
|
|
|
|
switch (Gbl.Prjs.Filter.Who)
|
|
|
|
|
{
|
|
|
|
|
case Usr_WHO_ME:
|
2019-11-14 02:29:18 +01:00
|
|
|
|
/* Get list of projects */
|
2019-11-11 15:46:54 +01:00
|
|
|
|
switch (Gbl.Prjs.SelectedOrder)
|
|
|
|
|
{
|
|
|
|
|
case Prj_ORDER_START_TIME:
|
|
|
|
|
case Prj_ORDER_END_TIME:
|
|
|
|
|
case Prj_ORDER_TITLE:
|
|
|
|
|
NumRows = DB_QuerySELECT (&mysql_res,"can not get projects",
|
|
|
|
|
"SELECT projects.PrjCod"
|
|
|
|
|
" FROM projects,prj_usr"
|
|
|
|
|
" WHERE projects.CrsCod=%ld"
|
|
|
|
|
"%s%s%s"
|
|
|
|
|
" AND projects.PrjCod=prj_usr.PrjCod"
|
|
|
|
|
" AND prj_usr.UsrCod=%ld"
|
2019-11-14 02:29:18 +01:00
|
|
|
|
" GROUP BY projects.PrjCod" // To not repeat projects (DISTINCT can not be used)
|
2019-11-11 15:46:54 +01:00
|
|
|
|
" ORDER BY %s",
|
|
|
|
|
Gbl.Hierarchy.Crs.CrsCod,
|
|
|
|
|
PreNonSubQuery,HidVisSubQuery,DptCodSubQuery,
|
|
|
|
|
Gbl.Usrs.Me.UsrDat.UsrCod,
|
|
|
|
|
OrderBySubQuery[Gbl.Prjs.SelectedOrder]);
|
|
|
|
|
break;
|
|
|
|
|
case Prj_ORDER_DEPARTMENT:
|
|
|
|
|
NumRows = DB_QuerySELECT (&mysql_res,"can not get projects",
|
|
|
|
|
"SELECT projects.PrjCod"
|
|
|
|
|
" FROM prj_usr,projects LEFT JOIN departments"
|
|
|
|
|
" ON projects.DptCod=departments.DptCod"
|
|
|
|
|
" WHERE projects.CrsCod=%ld"
|
|
|
|
|
"%s%s%s"
|
|
|
|
|
" AND projects.PrjCod=prj_usr.PrjCod"
|
|
|
|
|
" AND prj_usr.UsrCod=%ld"
|
2019-11-14 02:29:18 +01:00
|
|
|
|
" GROUP BY projects.PrjCod" // To not repeat projects (DISTINCT can not be used)
|
2019-11-11 15:46:54 +01:00
|
|
|
|
" ORDER BY %s",
|
|
|
|
|
Gbl.Hierarchy.Crs.CrsCod,
|
|
|
|
|
PreNonSubQuery,HidVisSubQuery,DptCodSubQuery,
|
|
|
|
|
Gbl.Usrs.Me.UsrDat.UsrCod,
|
|
|
|
|
OrderBySubQuery[Gbl.Prjs.SelectedOrder]);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
break;
|
2019-11-12 00:31:41 +01:00
|
|
|
|
case Usr_WHO_SELECTED:
|
2019-11-14 17:53:50 +01:00
|
|
|
|
/* Count number of valid users in list of encrypted user codes */
|
2019-11-15 03:34:48 +01:00
|
|
|
|
NumUsrsInList = Usr_CountNumUsrsInListOfSelectedEncryptedUsrCods (&Gbl.Usrs.Selected);
|
2019-11-14 02:29:18 +01:00
|
|
|
|
|
|
|
|
|
if (NumUsrsInList)
|
2019-11-13 21:31:06 +01:00
|
|
|
|
{
|
2019-11-14 02:29:18 +01:00
|
|
|
|
/* Get list of users selected to show their projects */
|
2019-11-15 03:34:48 +01:00
|
|
|
|
Usr_GetListSelectedUsrCods (&Gbl.Usrs.Selected,NumUsrsInList,&LstSelectedUsrCods);
|
2019-11-14 02:29:18 +01:00
|
|
|
|
|
|
|
|
|
/* Create subquery string */
|
|
|
|
|
Usr_CreateSubqueryUsrCods (LstSelectedUsrCods,NumUsrsInList,
|
|
|
|
|
&SubQueryUsrs);
|
|
|
|
|
|
|
|
|
|
/* Get list of projects */
|
|
|
|
|
switch (Gbl.Prjs.SelectedOrder)
|
|
|
|
|
{
|
|
|
|
|
case Prj_ORDER_START_TIME:
|
|
|
|
|
case Prj_ORDER_END_TIME:
|
|
|
|
|
case Prj_ORDER_TITLE:
|
|
|
|
|
NumRows = DB_QuerySELECT (&mysql_res,"can not get projects",
|
|
|
|
|
"SELECT projects.PrjCod"
|
|
|
|
|
" FROM projects,prj_usr"
|
|
|
|
|
" WHERE projects.CrsCod=%ld"
|
|
|
|
|
"%s%s%s"
|
|
|
|
|
" AND projects.PrjCod=prj_usr.PrjCod"
|
|
|
|
|
" AND prj_usr.UsrCod IN (%s)"
|
|
|
|
|
" GROUP BY projects.PrjCod" // To not repeat projects (DISTINCT can not be used)
|
|
|
|
|
" ORDER BY %s",
|
|
|
|
|
Gbl.Hierarchy.Crs.CrsCod,
|
|
|
|
|
PreNonSubQuery,HidVisSubQuery,DptCodSubQuery,
|
|
|
|
|
SubQueryUsrs,
|
|
|
|
|
OrderBySubQuery[Gbl.Prjs.SelectedOrder]);
|
|
|
|
|
break;
|
|
|
|
|
case Prj_ORDER_DEPARTMENT:
|
|
|
|
|
NumRows = DB_QuerySELECT (&mysql_res,"can not get projects",
|
|
|
|
|
"SELECT projects.PrjCod"
|
|
|
|
|
" FROM prj_usr,projects LEFT JOIN departments"
|
|
|
|
|
" ON projects.DptCod=departments.DptCod"
|
|
|
|
|
" WHERE projects.CrsCod=%ld"
|
|
|
|
|
"%s%s%s"
|
|
|
|
|
" AND projects.PrjCod=prj_usr.PrjCod"
|
|
|
|
|
" AND prj_usr.UsrCod IN (%s)"
|
|
|
|
|
" GROUP BY projects.PrjCod" // To not repeat projects (DISTINCT can not be used)
|
|
|
|
|
" ORDER BY %s",
|
|
|
|
|
Gbl.Hierarchy.Crs.CrsCod,
|
|
|
|
|
PreNonSubQuery,HidVisSubQuery,DptCodSubQuery,
|
|
|
|
|
SubQueryUsrs,
|
|
|
|
|
OrderBySubQuery[Gbl.Prjs.SelectedOrder]);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Free memory for subquery string */
|
|
|
|
|
Usr_FreeSubqueryUsrCods (SubQueryUsrs);
|
|
|
|
|
|
|
|
|
|
/* Free list of user codes */
|
|
|
|
|
Usr_FreeListSelectedUsrCods (LstSelectedUsrCods);
|
2019-11-13 21:31:06 +01:00
|
|
|
|
}
|
2019-11-14 02:29:18 +01:00
|
|
|
|
else
|
|
|
|
|
NumRows = 0;
|
2019-11-13 21:31:06 +01:00
|
|
|
|
break;
|
2019-11-11 15:46:54 +01:00
|
|
|
|
case Usr_WHO_ALL:
|
2019-11-14 02:29:18 +01:00
|
|
|
|
/* Get list of projects */
|
2019-11-11 15:46:54 +01:00
|
|
|
|
switch (Gbl.Prjs.SelectedOrder)
|
|
|
|
|
{
|
|
|
|
|
case Prj_ORDER_START_TIME:
|
|
|
|
|
case Prj_ORDER_END_TIME:
|
|
|
|
|
case Prj_ORDER_TITLE:
|
|
|
|
|
NumRows = DB_QuerySELECT (&mysql_res,"can not get projects",
|
|
|
|
|
"SELECT projects.PrjCod"
|
|
|
|
|
" FROM projects"
|
|
|
|
|
" WHERE projects.CrsCod=%ld"
|
|
|
|
|
"%s%s%s"
|
|
|
|
|
" ORDER BY %s",
|
|
|
|
|
Gbl.Hierarchy.Crs.CrsCod,
|
|
|
|
|
PreNonSubQuery,HidVisSubQuery,DptCodSubQuery,
|
|
|
|
|
OrderBySubQuery[Gbl.Prjs.SelectedOrder]);
|
|
|
|
|
break;
|
|
|
|
|
case Prj_ORDER_DEPARTMENT:
|
|
|
|
|
NumRows = DB_QuerySELECT (&mysql_res,"can not get projects",
|
|
|
|
|
"SELECT projects.PrjCod"
|
|
|
|
|
" FROM projects LEFT JOIN departments"
|
|
|
|
|
" ON projects.DptCod=departments.DptCod"
|
|
|
|
|
" WHERE projects.CrsCod=%ld"
|
|
|
|
|
"%s%s%s"
|
|
|
|
|
" ORDER BY %s",
|
|
|
|
|
Gbl.Hierarchy.Crs.CrsCod,
|
|
|
|
|
PreNonSubQuery,HidVisSubQuery,DptCodSubQuery,
|
|
|
|
|
OrderBySubQuery[Gbl.Prjs.SelectedOrder]);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
break;
|
2019-11-12 00:31:41 +01:00
|
|
|
|
default:
|
|
|
|
|
Lay_ShowErrorAndExit ("Wrong parameter which users.");
|
|
|
|
|
break;
|
2019-11-11 15:46:54 +01:00
|
|
|
|
}
|
2017-09-15 13:19:27 +02:00
|
|
|
|
|
2019-01-03 15:25:18 +01:00
|
|
|
|
/* Free allocated memory for subqueries */
|
2019-11-06 19:45:20 +01:00
|
|
|
|
free (PreNonSubQuery);
|
|
|
|
|
free (HidVisSubQuery);
|
|
|
|
|
free (DptCodSubQuery);
|
2019-01-03 15:25:18 +01:00
|
|
|
|
|
2017-10-10 01:26:45 +02:00
|
|
|
|
if (NumRows) // Projects found...
|
|
|
|
|
{
|
2019-10-17 00:18:31 +02:00
|
|
|
|
/***** Initialize number of projects *****/
|
|
|
|
|
NumPrjsFromDB = (unsigned) NumRows;
|
2017-09-15 13:19:27 +02:00
|
|
|
|
|
2017-10-10 01:26:45 +02:00
|
|
|
|
/***** Create list of projects *****/
|
|
|
|
|
if ((Gbl.Prjs.LstPrjCods = (long *) calloc (NumRows,sizeof (long))) == NULL)
|
2018-10-18 20:06:54 +02:00
|
|
|
|
Lay_NotEnoughMemoryExit ();
|
2017-09-15 13:19:27 +02:00
|
|
|
|
|
2017-10-10 01:26:45 +02:00
|
|
|
|
/***** Get the projects codes *****/
|
|
|
|
|
for (NumPrj = 0;
|
2019-10-17 00:18:31 +02:00
|
|
|
|
NumPrj < NumPrjsFromDB;
|
2017-10-10 01:26:45 +02:00
|
|
|
|
NumPrj++)
|
|
|
|
|
{
|
|
|
|
|
/* Get next project code */
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
2019-10-17 00:18:31 +02:00
|
|
|
|
if ((PrjCod = Str_ConvertStrCodToLongCod (row[0])) < 0)
|
2017-10-10 01:26:45 +02:00
|
|
|
|
Lay_ShowErrorAndExit ("Error: wrong project code.");
|
2019-10-17 00:18:31 +02:00
|
|
|
|
|
|
|
|
|
/* Filter projects depending on faultiness */
|
|
|
|
|
switch (Gbl.Prjs.Filter.Faulti)
|
|
|
|
|
{
|
|
|
|
|
case (1 << Prj_FAULTY): // Faulty projects
|
|
|
|
|
if (Prj_CheckIfPrjIsFaulty (PrjCod,&Faults))
|
|
|
|
|
Gbl.Prjs.LstPrjCods[NumPrjsAfterFilter++] = PrjCod;
|
|
|
|
|
break;
|
|
|
|
|
case (1 << Prj_FAULTLESS): // Faultless projects
|
|
|
|
|
if (!Prj_CheckIfPrjIsFaulty (PrjCod,&Faults))
|
|
|
|
|
Gbl.Prjs.LstPrjCods[NumPrjsAfterFilter++] = PrjCod;
|
|
|
|
|
break;
|
|
|
|
|
default: // All projects
|
|
|
|
|
Gbl.Prjs.LstPrjCods[NumPrjsAfterFilter++] = PrjCod;
|
|
|
|
|
break;
|
|
|
|
|
}
|
2017-10-10 01:26:45 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
}
|
2017-09-15 13:19:27 +02:00
|
|
|
|
|
2019-10-17 00:18:31 +02:00
|
|
|
|
Gbl.Prjs.Num = NumPrjsAfterFilter;
|
2017-09-17 16:58:09 +02:00
|
|
|
|
Gbl.Prjs.LstIsRead = true;
|
2017-09-15 13:19:27 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-10-07 12:28:19 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/****************** Check if a project exists in a course ********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
long Prj_GetCourseOfProject (long PrjCod)
|
|
|
|
|
{
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
|
|
|
|
long CrsCod = -1L;
|
|
|
|
|
|
|
|
|
|
if (PrjCod > 0)
|
|
|
|
|
{
|
|
|
|
|
/***** Get course code from database *****/
|
2018-11-01 19:23:52 +01:00
|
|
|
|
if (DB_QuerySELECT (&mysql_res,"can not get project course",
|
|
|
|
|
"SELECT CrsCod FROM projects WHERE PrjCod=%ld",
|
|
|
|
|
PrjCod)) // Project found...
|
2017-10-07 12:28:19 +02:00
|
|
|
|
{
|
|
|
|
|
/* Get row */
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
|
|
|
|
|
|
|
|
|
/* Get code of the course (row[0]) */
|
|
|
|
|
CrsCod = Str_ConvertStrCodToLongCod (row[0]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return CrsCod;
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-15 13:19:27 +02:00
|
|
|
|
/*****************************************************************************/
|
2017-09-17 16:58:09 +02:00
|
|
|
|
/********************* Get project data using its code ***********************/
|
2017-09-15 13:19:27 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Prj_GetDataOfProjectByCod (struct Project *Prj)
|
|
|
|
|
{
|
2018-11-01 19:23:52 +01:00
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
2019-09-23 01:48:28 +02:00
|
|
|
|
long LongNum;
|
2018-11-01 19:23:52 +01:00
|
|
|
|
Prj_Proposal_t Proposal;
|
2017-09-15 13:19:27 +02:00
|
|
|
|
|
2018-11-01 19:23:52 +01:00
|
|
|
|
if (Prj->PrjCod > 0)
|
2017-09-15 13:19:27 +02:00
|
|
|
|
{
|
|
|
|
|
/***** Clear all project data *****/
|
|
|
|
|
Prj_ResetProject (Prj);
|
|
|
|
|
|
2018-11-01 19:23:52 +01:00
|
|
|
|
/***** Get data of project *****/
|
|
|
|
|
if (DB_QuerySELECT (&mysql_res,"can not get project data",
|
|
|
|
|
"SELECT PrjCod," // row[ 0]
|
|
|
|
|
"CrsCod," // row[ 1]
|
|
|
|
|
"DptCod," // row[ 2]
|
2019-04-17 12:40:04 +02:00
|
|
|
|
"Locked," // row[ 3]
|
|
|
|
|
"Hidden," // row[ 4]
|
2019-10-25 22:48:34 +02:00
|
|
|
|
"Assigned," // row[ 5]
|
2019-04-17 12:40:04 +02:00
|
|
|
|
"NumStds," // row[ 6]
|
|
|
|
|
"Proposal," // row[ 7]
|
|
|
|
|
"UNIX_TIMESTAMP(CreatTime)," // row[ 8]
|
|
|
|
|
"UNIX_TIMESTAMP(ModifTime)," // row[ 9]
|
|
|
|
|
"Title," // row[10]
|
|
|
|
|
"Description," // row[11]
|
|
|
|
|
"Knowledge," // row[12]
|
|
|
|
|
"Materials," // row[13]
|
|
|
|
|
"URL" // row[14]
|
2018-11-01 19:23:52 +01:00
|
|
|
|
" FROM projects"
|
|
|
|
|
" WHERE PrjCod=%ld AND CrsCod=%ld",
|
|
|
|
|
Prj->PrjCod,
|
2019-04-04 10:45:15 +02:00
|
|
|
|
Gbl.Hierarchy.Crs.CrsCod)) // Project found...
|
2018-11-01 19:23:52 +01:00
|
|
|
|
{
|
|
|
|
|
/* Get row */
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
2017-09-15 13:19:27 +02:00
|
|
|
|
|
2018-11-01 19:23:52 +01:00
|
|
|
|
/* Get code of the project (row[0]) */
|
|
|
|
|
Prj->PrjCod = Str_ConvertStrCodToLongCod (row[0]);
|
2017-09-15 13:19:27 +02:00
|
|
|
|
|
2018-11-01 19:23:52 +01:00
|
|
|
|
/* Get code of the course (row[1]) */
|
|
|
|
|
Prj->CrsCod = Str_ConvertStrCodToLongCod (row[1]);
|
2017-09-15 13:19:27 +02:00
|
|
|
|
|
2018-11-01 19:23:52 +01:00
|
|
|
|
/* Get code of the department (row[2]) */
|
|
|
|
|
Prj->DptCod = Str_ConvertStrCodToLongCod (row[2]);
|
2017-10-02 01:16:10 +02:00
|
|
|
|
|
2019-04-17 12:40:04 +02:00
|
|
|
|
/* Get whether the project is locked or not (row[3]) */
|
|
|
|
|
Prj->Locked = (row[3][0] == 'Y') ? Prj_LOCKED :
|
|
|
|
|
Prj_UNLOCKED;
|
|
|
|
|
|
|
|
|
|
/* Get whether the project is hidden or not (row[4]) */
|
|
|
|
|
Prj->Hidden = (row[4][0] == 'Y') ? Prj_HIDDEN :
|
2018-11-01 19:23:52 +01:00
|
|
|
|
Prj_VISIBL;
|
2017-09-15 13:19:27 +02:00
|
|
|
|
|
2019-10-25 22:48:34 +02:00
|
|
|
|
/* Get if project is assigned or not (row[5]) */
|
2019-10-25 01:15:11 +02:00
|
|
|
|
Prj->Assigned = (row[5][0] == 'Y') ? Prj_ASSIGNED :
|
2019-10-25 22:48:34 +02:00
|
|
|
|
Prj_NONASSIG;
|
2017-09-15 13:19:27 +02:00
|
|
|
|
|
2019-10-25 22:48:34 +02:00
|
|
|
|
/* Get number of students (row[6]) */
|
2019-09-23 01:48:28 +02:00
|
|
|
|
LongNum = Str_ConvertStrCodToLongCod (row[6]);
|
2019-10-17 00:18:31 +02:00
|
|
|
|
Prj->NumStds = (LongNum > 0) ? (unsigned) LongNum :
|
|
|
|
|
0;
|
2017-09-15 13:19:27 +02:00
|
|
|
|
|
2019-04-17 12:40:04 +02:00
|
|
|
|
/* Get project status (row[7]) */
|
2018-11-01 19:23:52 +01:00
|
|
|
|
Prj->Proposal = Prj_PROPOSAL_DEFAULT;
|
|
|
|
|
for (Proposal = (Prj_Proposal_t) 0;
|
|
|
|
|
Proposal <= (Prj_Proposal_t) (Prj_NUM_PROPOSAL_TYPES - 1);
|
|
|
|
|
Proposal++)
|
2019-04-17 12:40:04 +02:00
|
|
|
|
if (!strcmp (Prj_Proposal_DB[Proposal],row[7]))
|
2018-11-01 19:23:52 +01:00
|
|
|
|
{
|
|
|
|
|
Prj->Proposal = Proposal;
|
|
|
|
|
break;
|
|
|
|
|
}
|
2017-09-19 01:12:05 +02:00
|
|
|
|
|
2019-04-17 12:40:04 +02:00
|
|
|
|
/* Get creation date/time (row[8] holds the creation UTC time) */
|
|
|
|
|
Prj->CreatTime = Dat_GetUNIXTimeFromStr (row[8]);
|
2017-09-15 13:19:27 +02:00
|
|
|
|
|
2019-04-17 12:40:04 +02:00
|
|
|
|
/* Get modification date/time (row[9] holds the modification UTC time) */
|
|
|
|
|
Prj->ModifTime = Dat_GetUNIXTimeFromStr (row[9]);
|
2017-09-19 01:12:05 +02:00
|
|
|
|
|
2019-04-17 12:40:04 +02:00
|
|
|
|
/* Get the title of the project (row[10]) */
|
|
|
|
|
Str_Copy (Prj->Title,row[10],
|
2018-11-01 19:23:52 +01:00
|
|
|
|
Prj_MAX_BYTES_PROJECT_TITLE);
|
2017-09-15 13:19:27 +02:00
|
|
|
|
|
2019-04-17 12:40:04 +02:00
|
|
|
|
/* Get the description of the project (row[11]) */
|
|
|
|
|
Str_Copy (Prj->Description,row[11],
|
2018-11-01 19:23:52 +01:00
|
|
|
|
Cns_MAX_BYTES_TEXT);
|
|
|
|
|
|
2019-04-17 12:40:04 +02:00
|
|
|
|
/* Get the required knowledge for the project (row[12]) */
|
|
|
|
|
Str_Copy (Prj->Knowledge,row[12],
|
2018-11-01 19:23:52 +01:00
|
|
|
|
Cns_MAX_BYTES_TEXT);
|
|
|
|
|
|
2019-04-17 12:40:04 +02:00
|
|
|
|
/* Get the required materials for the project (row[13]) */
|
|
|
|
|
Str_Copy (Prj->Materials,row[13],
|
2018-11-01 19:23:52 +01:00
|
|
|
|
Cns_MAX_BYTES_TEXT);
|
|
|
|
|
|
2019-04-17 12:40:04 +02:00
|
|
|
|
/* Get the URL of the project (row[14]) */
|
|
|
|
|
Str_Copy (Prj->URL,row[14],
|
2018-11-01 19:23:52 +01:00
|
|
|
|
Cns_MAX_BYTES_WWW);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/***** Clear all project data *****/
|
|
|
|
|
Prj->PrjCod = -1L;
|
|
|
|
|
Prj_ResetProject (Prj);
|
|
|
|
|
}
|
2017-09-15 13:19:27 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2017-09-17 16:58:09 +02:00
|
|
|
|
/************************** Clear all project data ***************************/
|
2017-09-15 13:19:27 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Prj_ResetProject (struct Project *Prj)
|
|
|
|
|
{
|
|
|
|
|
if (Prj->PrjCod <= 0) // If > 0 ==> keep value
|
|
|
|
|
Prj->PrjCod = -1L;
|
2019-10-25 22:48:34 +02:00
|
|
|
|
Prj->CrsCod = -1L;
|
|
|
|
|
Prj->Locked = Prj_UNLOCKED;
|
|
|
|
|
Prj->Hidden = Prj_NEW_PRJ_HIDDEN_VISIBL_DEFAULT;
|
|
|
|
|
Prj->Assigned = Prj_NEW_PRJ_ASSIGNED_NONASSIG_DEFAULT;
|
|
|
|
|
Prj->NumStds = 1;
|
|
|
|
|
Prj->Proposal = Prj_PROPOSAL_DEFAULT;
|
2017-10-07 22:08:38 +02:00
|
|
|
|
Prj->CreatTime =
|
|
|
|
|
Prj->ModifTime = (time_t) 0;
|
2019-10-25 22:48:34 +02:00
|
|
|
|
Prj->Title[0] = '\0';
|
|
|
|
|
Prj->DptCod = -1L; // Unknown department
|
2017-09-19 01:12:05 +02:00
|
|
|
|
Prj->Description[0] = '\0';
|
2017-10-02 01:16:10 +02:00
|
|
|
|
Prj->Knowledge[0] = '\0';
|
|
|
|
|
Prj->Materials[0] = '\0';
|
2017-10-06 15:13:19 +02:00
|
|
|
|
Prj->URL[0] = '\0';
|
2017-09-15 13:19:27 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2017-09-17 16:58:09 +02:00
|
|
|
|
/*************************** Free list of projects ***************************/
|
2017-09-15 13:19:27 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Prj_FreeListProjects (void)
|
|
|
|
|
{
|
2017-09-17 16:58:09 +02:00
|
|
|
|
if (Gbl.Prjs.LstIsRead && Gbl.Prjs.LstPrjCods)
|
2017-09-15 13:19:27 +02:00
|
|
|
|
{
|
|
|
|
|
/***** Free memory used by the list of projects *****/
|
2019-11-06 19:45:20 +01:00
|
|
|
|
free (Gbl.Prjs.LstPrjCods);
|
2017-09-17 16:58:09 +02:00
|
|
|
|
Gbl.Prjs.LstPrjCods = NULL;
|
|
|
|
|
Gbl.Prjs.Num = 0;
|
|
|
|
|
Gbl.Prjs.LstIsRead = false;
|
2017-09-15 13:19:27 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2017-09-17 16:58:09 +02:00
|
|
|
|
/******************* Write parameter with code of project ********************/
|
2017-09-15 13:19:27 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2017-10-06 20:56:01 +02:00
|
|
|
|
void Prj_PutParamPrjCod (long PrjCod)
|
2017-09-15 13:19:27 +02:00
|
|
|
|
{
|
2019-11-03 13:19:32 +01:00
|
|
|
|
Par_PutHiddenParamLong (NULL,"PrjCod",PrjCod);
|
2017-09-15 13:19:27 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2017-09-17 16:58:09 +02:00
|
|
|
|
/******************** Get parameter with code of project *********************/
|
2017-09-15 13:19:27 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
long Prj_GetParamPrjCod (void)
|
|
|
|
|
{
|
|
|
|
|
/***** Get code of project *****/
|
|
|
|
|
return Par_GetParToLong ("PrjCod");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2017-09-21 12:43:35 +02:00
|
|
|
|
/**************** Ask for confirmation of removing a project *****************/
|
2017-09-15 13:19:27 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Prj_ReqRemProject (void)
|
|
|
|
|
{
|
2017-09-17 16:58:09 +02:00
|
|
|
|
extern const char *Txt_Do_you_really_want_to_remove_the_project_X;
|
|
|
|
|
extern const char *Txt_Remove_project;
|
2017-09-15 13:19:27 +02:00
|
|
|
|
struct Project Prj;
|
|
|
|
|
|
2017-09-21 12:43:35 +02:00
|
|
|
|
/***** Allocate memory for the project *****/
|
|
|
|
|
Prj_AllocMemProject (&Prj);
|
|
|
|
|
|
2017-09-15 13:19:27 +02:00
|
|
|
|
/***** Get parameters *****/
|
2017-10-10 01:26:45 +02:00
|
|
|
|
Prj_GetParams ();
|
2017-10-07 18:11:49 +02:00
|
|
|
|
if ((Prj.PrjCod = Prj_GetParamPrjCod ()) < 0)
|
2017-09-15 13:19:27 +02:00
|
|
|
|
Lay_ShowErrorAndExit ("Code of project is missing.");
|
|
|
|
|
|
|
|
|
|
/***** Get data of the project from database *****/
|
|
|
|
|
Prj_GetDataOfProjectByCod (&Prj);
|
|
|
|
|
|
2019-04-18 11:10:39 +02:00
|
|
|
|
if (Prj_CheckIfICanEditProject (&Prj))
|
2017-09-25 00:22:54 +02:00
|
|
|
|
{
|
|
|
|
|
/***** Show question and button to remove the project *****/
|
2017-10-10 01:26:45 +02:00
|
|
|
|
Gbl.Prjs.PrjCod = Prj.PrjCod;
|
2019-02-17 01:14:55 +01:00
|
|
|
|
Ale_ShowAlertAndButton (ActRemPrj,NULL,NULL,Prj_PutCurrentParams,
|
|
|
|
|
Btn_REMOVE_BUTTON,Txt_Remove_project,
|
|
|
|
|
Ale_QUESTION,Txt_Do_you_really_want_to_remove_the_project_X,
|
|
|
|
|
Prj.Title);
|
2017-09-25 00:22:54 +02:00
|
|
|
|
}
|
|
|
|
|
else
|
2019-10-26 01:56:36 +02:00
|
|
|
|
Lay_NoPermissionExit ();
|
2017-09-15 13:19:27 +02:00
|
|
|
|
|
2017-09-21 12:43:35 +02:00
|
|
|
|
/***** Free memory of the project *****/
|
|
|
|
|
Prj_FreeMemProject (&Prj);
|
|
|
|
|
|
2017-09-15 13:19:27 +02:00
|
|
|
|
/***** Show projects again *****/
|
2019-11-15 03:34:48 +01:00
|
|
|
|
Prj_ShowProjects ();
|
2017-09-15 13:19:27 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2017-09-17 16:58:09 +02:00
|
|
|
|
/***************************** Remove a project ******************************/
|
2017-09-15 13:19:27 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Prj_RemoveProject (void)
|
|
|
|
|
{
|
2017-09-17 18:55:02 +02:00
|
|
|
|
extern const char *Txt_Project_X_removed;
|
2017-09-15 13:19:27 +02:00
|
|
|
|
struct Project Prj;
|
2017-10-08 00:51:49 +02:00
|
|
|
|
char PathRelPrj[PATH_MAX + 1];
|
2017-09-15 13:19:27 +02:00
|
|
|
|
|
2017-09-21 12:43:35 +02:00
|
|
|
|
/***** Allocate memory for the project *****/
|
|
|
|
|
Prj_AllocMemProject (&Prj);
|
|
|
|
|
|
|
|
|
|
/***** Get parameters *****/
|
2017-10-10 01:26:45 +02:00
|
|
|
|
Prj_GetParams ();
|
2017-10-07 18:11:49 +02:00
|
|
|
|
if ((Prj.PrjCod = Prj_GetParamPrjCod ()) < 0)
|
2017-09-15 13:19:27 +02:00
|
|
|
|
Lay_ShowErrorAndExit ("Code of project is missing.");
|
|
|
|
|
|
|
|
|
|
/***** Get data of the project from database *****/
|
|
|
|
|
Prj_GetDataOfProjectByCod (&Prj); // Inside this function, the course is checked to be the current one
|
|
|
|
|
|
2019-04-18 11:10:39 +02:00
|
|
|
|
if (Prj_CheckIfICanEditProject (&Prj))
|
2017-09-25 00:22:54 +02:00
|
|
|
|
{
|
|
|
|
|
/***** Remove users in project *****/
|
2018-11-02 22:00:31 +01:00
|
|
|
|
DB_QueryDELETE ("can not remove project",
|
|
|
|
|
"DELETE FROM prj_usr USING projects,prj_usr"
|
|
|
|
|
" WHERE projects.PrjCod=%ld AND projects.CrsCod=%ld"
|
|
|
|
|
" AND projects.PrjCod=prj_usr.PrjCod",
|
2019-04-04 10:45:15 +02:00
|
|
|
|
Prj.PrjCod,Gbl.Hierarchy.Crs.CrsCod);
|
2017-09-25 00:22:54 +02:00
|
|
|
|
|
2017-10-08 16:12:58 +02:00
|
|
|
|
/***** Flush cache *****/
|
2019-04-11 15:24:05 +02:00
|
|
|
|
Prj_FlushCacheMyRolesInProject ();
|
2017-10-08 16:12:58 +02:00
|
|
|
|
|
2017-09-25 00:22:54 +02:00
|
|
|
|
/***** Remove project *****/
|
2018-11-02 22:00:31 +01:00
|
|
|
|
DB_QueryDELETE ("can not remove project",
|
|
|
|
|
"DELETE FROM projects"
|
|
|
|
|
" WHERE PrjCod=%ld AND CrsCod=%ld",
|
2019-04-04 10:45:15 +02:00
|
|
|
|
Prj.PrjCod,Gbl.Hierarchy.Crs.CrsCod);
|
2017-09-15 13:19:27 +02:00
|
|
|
|
|
2017-10-08 01:15:49 +02:00
|
|
|
|
/***** Remove information related to files in project *****/
|
|
|
|
|
Brw_RemovePrjFilesFromDB (Prj.PrjCod);
|
|
|
|
|
|
2017-10-08 00:51:49 +02:00
|
|
|
|
/***** Remove directory of the project *****/
|
2018-10-18 02:02:32 +02:00
|
|
|
|
snprintf (PathRelPrj,sizeof (PathRelPrj),
|
2019-03-20 01:36:36 +01:00
|
|
|
|
"%s/%ld/%s/%02u/%ld",
|
|
|
|
|
Cfg_PATH_CRS_PRIVATE,Prj.CrsCod,Cfg_FOLDER_PRJ,
|
2018-10-18 02:02:32 +02:00
|
|
|
|
(unsigned) (Prj.PrjCod % 100),Prj.PrjCod);
|
2017-10-08 00:51:49 +02:00
|
|
|
|
Fil_RemoveTree (PathRelPrj);
|
|
|
|
|
|
2017-09-25 00:22:54 +02:00
|
|
|
|
/***** Write message to show the change made *****/
|
2019-02-16 18:25:41 +01:00
|
|
|
|
Ale_ShowAlert (Ale_SUCCESS,Txt_Project_X_removed,
|
|
|
|
|
Prj.Title);
|
2017-09-25 00:22:54 +02:00
|
|
|
|
}
|
|
|
|
|
else
|
2019-10-26 01:56:36 +02:00
|
|
|
|
Lay_NoPermissionExit ();
|
2017-09-15 13:19:27 +02:00
|
|
|
|
|
2017-09-21 12:43:35 +02:00
|
|
|
|
/***** Free memory of the project *****/
|
|
|
|
|
Prj_FreeMemProject (&Prj);
|
|
|
|
|
|
2017-09-15 13:19:27 +02:00
|
|
|
|
/***** Show projects again *****/
|
2019-11-15 03:34:48 +01:00
|
|
|
|
Prj_ShowProjects ();
|
2017-09-15 13:19:27 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2017-09-17 16:58:09 +02:00
|
|
|
|
/****************************** Hide a project *******************************/
|
2017-09-15 13:19:27 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Prj_HideProject (void)
|
|
|
|
|
{
|
|
|
|
|
struct Project Prj;
|
|
|
|
|
|
2017-09-19 09:35:36 +02:00
|
|
|
|
/***** Allocate memory for the project *****/
|
|
|
|
|
Prj_AllocMemProject (&Prj);
|
|
|
|
|
|
2017-10-07 18:11:49 +02:00
|
|
|
|
/***** Get parameters *****/
|
2017-10-10 01:26:45 +02:00
|
|
|
|
Prj_GetParams ();
|
2017-10-07 18:11:49 +02:00
|
|
|
|
if ((Prj.PrjCod = Prj_GetParamPrjCod ()) < 0)
|
2017-09-15 13:19:27 +02:00
|
|
|
|
Lay_ShowErrorAndExit ("Code of project is missing.");
|
|
|
|
|
|
|
|
|
|
/***** Get data of the project from database *****/
|
|
|
|
|
Prj_GetDataOfProjectByCod (&Prj);
|
|
|
|
|
|
2019-04-18 11:10:39 +02:00
|
|
|
|
if (Prj_CheckIfICanEditProject (&Prj))
|
2017-09-25 00:22:54 +02:00
|
|
|
|
/***** Hide project *****/
|
2018-11-03 12:16:40 +01:00
|
|
|
|
DB_QueryUPDATE ("can not hide project",
|
|
|
|
|
"UPDATE projects SET Hidden='Y'"
|
|
|
|
|
" WHERE PrjCod=%ld AND CrsCod=%ld",
|
2019-04-04 10:45:15 +02:00
|
|
|
|
Prj.PrjCod,Gbl.Hierarchy.Crs.CrsCod);
|
2017-09-25 00:22:54 +02:00
|
|
|
|
else
|
2019-10-26 01:56:36 +02:00
|
|
|
|
Lay_NoPermissionExit ();
|
2017-09-15 13:19:27 +02:00
|
|
|
|
|
2017-09-19 09:35:36 +02:00
|
|
|
|
/***** Free memory of the project *****/
|
|
|
|
|
Prj_FreeMemProject (&Prj);
|
|
|
|
|
|
2017-09-15 13:19:27 +02:00
|
|
|
|
/***** Show projects again *****/
|
2019-11-15 03:34:48 +01:00
|
|
|
|
Prj_ShowProjects ();
|
2017-09-15 13:19:27 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2019-11-15 03:34:48 +01:00
|
|
|
|
/****************************** Unhide a project *****************************/
|
2017-09-15 13:19:27 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2019-11-15 03:34:48 +01:00
|
|
|
|
void Prj_UnhideProject (void)
|
2017-09-15 13:19:27 +02:00
|
|
|
|
{
|
|
|
|
|
struct Project Prj;
|
|
|
|
|
|
2017-09-19 09:35:36 +02:00
|
|
|
|
/***** Allocate memory for the project *****/
|
|
|
|
|
Prj_AllocMemProject (&Prj);
|
|
|
|
|
|
2017-10-07 18:11:49 +02:00
|
|
|
|
/***** Get parameters *****/
|
2017-10-10 01:26:45 +02:00
|
|
|
|
Prj_GetParams ();
|
2017-10-07 18:11:49 +02:00
|
|
|
|
if ((Prj.PrjCod = Prj_GetParamPrjCod ()) < 0)
|
2017-09-15 13:19:27 +02:00
|
|
|
|
Lay_ShowErrorAndExit ("Code of project is missing.");
|
|
|
|
|
|
|
|
|
|
/***** Get data of the project from database *****/
|
|
|
|
|
Prj_GetDataOfProjectByCod (&Prj);
|
|
|
|
|
|
2019-04-18 11:10:39 +02:00
|
|
|
|
if (Prj_CheckIfICanEditProject (&Prj))
|
2017-09-25 00:22:54 +02:00
|
|
|
|
/***** Show project *****/
|
2018-11-03 12:16:40 +01:00
|
|
|
|
DB_QueryUPDATE ("can not show project",
|
|
|
|
|
"UPDATE projects SET Hidden='N'"
|
|
|
|
|
" WHERE PrjCod=%ld AND CrsCod=%ld",
|
2019-04-04 10:45:15 +02:00
|
|
|
|
Prj.PrjCod,Gbl.Hierarchy.Crs.CrsCod);
|
2017-09-25 00:22:54 +02:00
|
|
|
|
else
|
2019-10-26 01:56:36 +02:00
|
|
|
|
Lay_NoPermissionExit ();
|
2017-09-15 13:19:27 +02:00
|
|
|
|
|
2017-09-19 09:35:36 +02:00
|
|
|
|
/***** Free memory of the project *****/
|
|
|
|
|
Prj_FreeMemProject (&Prj);
|
|
|
|
|
|
2017-09-15 13:19:27 +02:00
|
|
|
|
/***** Show projects again *****/
|
2019-11-15 03:34:48 +01:00
|
|
|
|
Prj_ShowProjects ();
|
2017-09-15 13:19:27 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-04-17 12:40:04 +02:00
|
|
|
|
/*****************************************************************************/
|
2019-10-25 22:48:34 +02:00
|
|
|
|
/********************* Put a form to create/edit project *********************/
|
2019-04-17 12:40:04 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2019-10-25 22:48:34 +02:00
|
|
|
|
void Prj_RequestCreatePrj (void)
|
2019-04-17 12:40:04 +02:00
|
|
|
|
{
|
2019-10-25 22:48:34 +02:00
|
|
|
|
/***** Form to create project *****/
|
|
|
|
|
Prj_RequestCreatOrEditPrj (-1L); // It's a new, non existing, project
|
|
|
|
|
}
|
2019-04-17 12:40:04 +02:00
|
|
|
|
|
2019-10-25 22:48:34 +02:00
|
|
|
|
void Prj_RequestEditPrj (void)
|
|
|
|
|
{
|
|
|
|
|
long PrjCod;
|
2019-04-17 12:40:04 +02:00
|
|
|
|
|
2019-10-25 22:48:34 +02:00
|
|
|
|
/***** Get project code *****/
|
|
|
|
|
if ((PrjCod = Prj_GetParamPrjCod ()) == -1L)
|
2019-04-17 12:40:04 +02:00
|
|
|
|
Lay_ShowErrorAndExit ("Code of project is missing.");
|
|
|
|
|
|
2019-10-25 22:48:34 +02:00
|
|
|
|
/***** Form to edit project *****/
|
|
|
|
|
Prj_RequestCreatOrEditPrj (PrjCod);
|
2019-04-18 14:06:00 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-10-25 22:48:34 +02:00
|
|
|
|
static void Prj_RequestCreatOrEditPrj (long PrjCod)
|
2019-04-17 12:40:04 +02:00
|
|
|
|
{
|
|
|
|
|
struct Project Prj;
|
2019-10-25 22:48:34 +02:00
|
|
|
|
bool ItsANewProject;
|
2019-04-17 12:40:04 +02:00
|
|
|
|
|
|
|
|
|
/***** Allocate memory for the project *****/
|
|
|
|
|
Prj_AllocMemProject (&Prj);
|
|
|
|
|
|
|
|
|
|
/***** Get parameters *****/
|
|
|
|
|
Prj_GetParams ();
|
2019-10-25 22:48:34 +02:00
|
|
|
|
ItsANewProject = ((Prj.PrjCod = PrjCod) < 0);
|
2019-04-17 12:40:04 +02:00
|
|
|
|
|
2019-10-25 22:48:34 +02:00
|
|
|
|
/***** Get from the database the data of the project *****/
|
|
|
|
|
if (ItsANewProject)
|
2019-04-17 12:40:04 +02:00
|
|
|
|
{
|
2019-10-25 22:48:34 +02:00
|
|
|
|
/* Initialize to empty project */
|
|
|
|
|
Prj_ResetProject (&Prj);
|
|
|
|
|
Prj.CreatTime = Gbl.StartExecutionTimeUTC;
|
|
|
|
|
Prj.ModifTime = Gbl.StartExecutionTimeUTC;
|
|
|
|
|
Prj.DptCod = Gbl.Usrs.Me.UsrDat.Tch.DptCod; // Default: my department
|
2019-04-17 12:40:04 +02:00
|
|
|
|
}
|
|
|
|
|
else
|
2019-10-25 22:48:34 +02:00
|
|
|
|
/* Get data of the project from database */
|
|
|
|
|
Prj_GetDataOfProjectByCod (&Prj);
|
|
|
|
|
|
|
|
|
|
/***** Put form to edit project *****/
|
|
|
|
|
Prj_PutFormProject (&Prj,ItsANewProject);
|
2019-04-17 12:40:04 +02:00
|
|
|
|
|
|
|
|
|
/***** Free memory of the project *****/
|
|
|
|
|
Prj_FreeMemProject (&Prj);
|
|
|
|
|
|
2019-10-25 22:48:34 +02:00
|
|
|
|
/***** Show projects again *****/
|
2019-11-15 03:34:48 +01:00
|
|
|
|
Prj_ShowProjects ();
|
2019-04-18 14:06:00 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-10-25 22:48:34 +02:00
|
|
|
|
static void Prj_PutFormProject (struct Project *Prj,bool ItsANewProject)
|
2019-04-18 14:06:00 +02:00
|
|
|
|
{
|
2019-10-25 22:48:34 +02:00
|
|
|
|
extern const char *Hlp_ASSESSMENT_Projects_new_project;
|
|
|
|
|
extern const char *Hlp_ASSESSMENT_Projects_edit_project;
|
|
|
|
|
extern const char *The_ClassFormInBox[The_NUM_THEMES];
|
|
|
|
|
extern const char *Txt_New_project;
|
|
|
|
|
extern const char *Txt_Edit_project;
|
|
|
|
|
extern const char *Txt_Data;
|
|
|
|
|
extern const char *Txt_Title;
|
|
|
|
|
extern const char *Txt_Department;
|
|
|
|
|
extern const char *Txt_Another_department;
|
|
|
|
|
extern const char *Txt_Assigned_QUESTION;
|
|
|
|
|
extern const char *Txt_Number_of_students;
|
|
|
|
|
extern const char *Txt_Proposal;
|
|
|
|
|
extern const char *Txt_PROJECT_STATUS[Prj_NUM_PROPOSAL_TYPES];
|
|
|
|
|
extern const char *Txt_Description;
|
|
|
|
|
extern const char *Txt_Required_knowledge;
|
|
|
|
|
extern const char *Txt_Required_materials;
|
|
|
|
|
extern const char *Txt_URL;
|
|
|
|
|
extern const char *Txt_No;
|
|
|
|
|
extern const char *Txt_Yes;
|
|
|
|
|
extern const char *Txt_Create_project;
|
|
|
|
|
extern const char *Txt_Save_changes;
|
|
|
|
|
extern const char *Txt_Members;
|
|
|
|
|
Prj_Proposal_t Proposal;
|
2019-11-06 15:27:33 +01:00
|
|
|
|
unsigned ProposalUnsigned;
|
2019-10-25 22:48:34 +02:00
|
|
|
|
unsigned NumRoleToShow;
|
2019-04-18 14:06:00 +02:00
|
|
|
|
|
2019-10-25 22:48:34 +02:00
|
|
|
|
/***** Start project box *****/
|
|
|
|
|
if (ItsANewProject)
|
2019-04-18 14:06:00 +02:00
|
|
|
|
{
|
2019-10-25 22:48:34 +02:00
|
|
|
|
Gbl.Prjs.PrjCod = -1L;
|
|
|
|
|
Box_BoxBegin (NULL,Txt_New_project,NULL,
|
|
|
|
|
Hlp_ASSESSMENT_Projects_new_project,Box_NOT_CLOSABLE);
|
2019-04-18 14:06:00 +02:00
|
|
|
|
}
|
|
|
|
|
else
|
2019-10-25 22:48:34 +02:00
|
|
|
|
{
|
|
|
|
|
Gbl.Prjs.PrjCod = Prj->PrjCod;
|
|
|
|
|
Box_BoxBegin (NULL,
|
|
|
|
|
Prj->Title[0] ? Prj->Title :
|
|
|
|
|
Txt_Edit_project,
|
|
|
|
|
NULL,
|
|
|
|
|
Hlp_ASSESSMENT_Projects_edit_project,Box_NOT_CLOSABLE);
|
|
|
|
|
}
|
2017-09-15 13:19:27 +02:00
|
|
|
|
|
2017-09-29 18:28:04 +02:00
|
|
|
|
/***** 1. Project members *****/
|
|
|
|
|
if (!ItsANewProject) // Existing project
|
|
|
|
|
{
|
2019-11-25 23:18:08 +01:00
|
|
|
|
Box_BoxTableBegin (NULL,Txt_Members,NULL,
|
2017-09-29 18:28:04 +02:00
|
|
|
|
NULL,Box_NOT_CLOSABLE,2);
|
2017-10-01 00:48:36 +02:00
|
|
|
|
for (NumRoleToShow = 0;
|
|
|
|
|
NumRoleToShow < Brw_NUM_ROLES_TO_SHOW;
|
|
|
|
|
NumRoleToShow++)
|
|
|
|
|
Prj_ShowOneProjectMembersWithARole (Prj,Prj_EDIT_ONE_PROJECT,
|
|
|
|
|
Prj_RolesToShow[NumRoleToShow]);
|
2019-11-25 23:18:08 +01:00
|
|
|
|
Box_BoxTableEnd ();
|
2017-09-29 18:28:04 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** 2. Project data *****/
|
2017-10-01 11:57:25 +02:00
|
|
|
|
/* Start data form */
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_StartForm (ItsANewProject ? ActNewPrj :
|
2017-10-01 11:57:25 +02:00
|
|
|
|
ActChgPrj);
|
2017-10-10 01:26:45 +02:00
|
|
|
|
Prj_PutCurrentParams ();
|
2017-10-01 11:57:25 +02:00
|
|
|
|
|
2019-10-26 02:19:42 +02:00
|
|
|
|
/* Begin box and table */
|
2019-11-25 23:18:08 +01:00
|
|
|
|
Box_BoxTableBegin (NULL,Txt_Data,NULL,
|
2017-09-20 23:25:55 +02:00
|
|
|
|
NULL,Box_NOT_CLOSABLE,2);
|
2017-09-15 13:19:27 +02:00
|
|
|
|
|
2017-09-20 23:25:55 +02:00
|
|
|
|
/* Project title */
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_Begin (NULL);
|
2019-10-07 20:17:29 +02:00
|
|
|
|
|
2019-12-27 21:10:39 +01:00
|
|
|
|
/* Label */
|
2019-12-27 15:45:19 +01:00
|
|
|
|
Frm_LabelColumn ("RT","Title",Txt_Title);
|
2019-10-07 20:17:29 +02:00
|
|
|
|
|
2019-12-27 21:10:39 +01:00
|
|
|
|
/* Data */
|
2019-12-26 22:29:04 +01:00
|
|
|
|
HTM_TD_Begin ("class=\"LT\"");
|
2019-11-04 12:25:48 +01:00
|
|
|
|
HTM_INPUT_TEXT ("Title",Prj_MAX_CHARS_PROJECT_TITLE,Prj->Title,false,
|
2019-11-27 00:27:42 +01:00
|
|
|
|
"id=\"Title\" required=\"required\""
|
|
|
|
|
" class=\"TITLE_DESCRIPTION_WIDTH\"");
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2019-10-07 20:17:29 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_End ();
|
2017-09-15 13:19:27 +02:00
|
|
|
|
|
2017-09-21 21:58:14 +02:00
|
|
|
|
/* Department */
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_Begin (NULL);
|
2019-10-07 20:17:29 +02:00
|
|
|
|
|
2019-12-27 21:10:39 +01:00
|
|
|
|
/* Label */
|
2019-12-27 15:45:19 +01:00
|
|
|
|
Frm_LabelColumn ("RT",Dpt_PARAM_DPT_COD_NAME,Txt_Department);
|
2019-10-07 20:17:29 +02:00
|
|
|
|
|
2019-12-27 21:10:39 +01:00
|
|
|
|
/* Data */
|
2019-12-26 22:29:04 +01:00
|
|
|
|
HTM_TD_Begin ("class=\"LT\"");
|
2019-04-03 20:57:04 +02:00
|
|
|
|
Dpt_WriteSelectorDepartment (Gbl.Hierarchy.Ins.InsCod, // Departments in current institution
|
2017-10-10 10:46:35 +02:00
|
|
|
|
Prj->DptCod, // Selected department
|
2019-11-27 00:27:42 +01:00
|
|
|
|
"TITLE_DESCRIPTION_WIDTH", // Selector class
|
2017-10-10 10:46:35 +02:00
|
|
|
|
0, // First option
|
|
|
|
|
Txt_Another_department, // Text when no department selected
|
|
|
|
|
false); // Don't submit on change
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2019-10-07 20:17:29 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_End ();
|
2017-09-21 21:58:14 +02:00
|
|
|
|
|
2019-10-25 22:48:34 +02:00
|
|
|
|
/* Assigned? */
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_Begin (NULL);
|
2019-10-07 20:17:29 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"%s RM\"",The_ClassFormInBox[Gbl.Prefs.Theme]);
|
2019-11-11 10:59:24 +01:00
|
|
|
|
HTM_TxtF ("%s:",Txt_Assigned_QUESTION);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2019-10-07 20:17:29 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"LM\"");
|
2019-11-05 15:47:35 +01:00
|
|
|
|
HTM_SELECT_Begin (false,
|
|
|
|
|
"name=\"Assigned\"");
|
2019-11-06 19:45:20 +01:00
|
|
|
|
HTM_OPTION (HTM_Type_STRING,"Y",Prj->Assigned == Prj_ASSIGNED,false,
|
2019-11-06 08:59:15 +01:00
|
|
|
|
"%s",Txt_Yes);
|
2019-11-06 19:45:20 +01:00
|
|
|
|
HTM_OPTION (HTM_Type_STRING,"N",Prj->Assigned == Prj_NONASSIG,false,
|
2019-11-06 08:59:15 +01:00
|
|
|
|
"%s",Txt_No);
|
2019-11-05 08:46:38 +01:00
|
|
|
|
HTM_SELECT_End ();
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2019-10-07 20:17:29 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_End ();
|
2017-10-01 18:44:50 +02:00
|
|
|
|
|
2017-10-02 02:19:14 +02:00
|
|
|
|
/* Number of students */
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_Begin (NULL);
|
2019-10-07 20:17:29 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"%s RM\"",The_ClassFormInBox[Gbl.Prefs.Theme]);
|
2019-11-11 10:59:24 +01:00
|
|
|
|
HTM_TxtF ("%s:",Txt_Number_of_students);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2019-10-07 20:17:29 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"LM\"");
|
2019-11-27 01:01:27 +01:00
|
|
|
|
HTM_INPUT_LONG ("NumStds",(long) 0,(long) UINT_MAX,(long) Prj->NumStds,false,
|
2019-11-12 15:41:58 +01:00
|
|
|
|
NULL);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2019-10-07 20:17:29 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_End ();
|
2017-10-02 02:19:14 +02:00
|
|
|
|
|
2017-10-02 19:34:31 +02:00
|
|
|
|
/* Proposal */
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_Begin (NULL);
|
2019-10-07 20:17:29 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"%s RM\"",The_ClassFormInBox[Gbl.Prefs.Theme]);
|
2019-11-11 10:59:24 +01:00
|
|
|
|
HTM_TxtF ("%s:",Txt_Proposal);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2019-10-07 20:17:29 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"LM\"");
|
2019-11-05 15:47:35 +01:00
|
|
|
|
HTM_SELECT_Begin (false,
|
2019-11-27 00:27:42 +01:00
|
|
|
|
"name=\"Proposal\" class=\"TITLE_DESCRIPTION_WIDTH\"");
|
2017-10-02 19:34:31 +02:00
|
|
|
|
for (Proposal = (Prj_Proposal_t) 0;
|
|
|
|
|
Proposal <= (Prj_Proposal_t) (Prj_NUM_PROPOSAL_TYPES - 1);
|
|
|
|
|
Proposal++)
|
2017-10-02 01:16:10 +02:00
|
|
|
|
{
|
2019-11-06 15:27:33 +01:00
|
|
|
|
ProposalUnsigned = (unsigned) Proposal;
|
2019-11-06 19:45:20 +01:00
|
|
|
|
HTM_OPTION (HTM_Type_UNSIGNED,&ProposalUnsigned,
|
2019-11-06 15:27:33 +01:00
|
|
|
|
Prj->Proposal == Proposal,false,
|
|
|
|
|
"%s",Txt_PROJECT_STATUS[Proposal]);
|
2017-10-02 01:16:10 +02:00
|
|
|
|
}
|
2019-11-05 08:46:38 +01:00
|
|
|
|
HTM_SELECT_End ();
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2019-10-07 20:17:29 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_End ();
|
2017-10-02 01:16:10 +02:00
|
|
|
|
|
2017-09-20 23:25:55 +02:00
|
|
|
|
/* Description of the project */
|
2017-09-23 15:39:21 +02:00
|
|
|
|
Prj_EditOneProjectTxtArea ("Description",Txt_Description,
|
2019-10-14 02:21:41 +02:00
|
|
|
|
Prj->Description,12,
|
|
|
|
|
true); // Required
|
2017-09-19 01:12:05 +02:00
|
|
|
|
|
2017-09-20 23:25:55 +02:00
|
|
|
|
/* Required knowledge to carry out the project */
|
2017-09-23 15:39:21 +02:00
|
|
|
|
Prj_EditOneProjectTxtArea ("Knowledge",Txt_Required_knowledge,
|
2019-10-14 02:21:41 +02:00
|
|
|
|
Prj->Knowledge,4,
|
|
|
|
|
false); // Not required
|
2017-09-19 01:12:05 +02:00
|
|
|
|
|
2017-09-20 23:25:55 +02:00
|
|
|
|
/* Required materials to carry out the project */
|
2017-09-23 15:39:21 +02:00
|
|
|
|
Prj_EditOneProjectTxtArea ("Materials",Txt_Required_materials,
|
2019-10-14 02:21:41 +02:00
|
|
|
|
Prj->Materials,4,
|
|
|
|
|
false); // Not required
|
2017-09-15 13:19:27 +02:00
|
|
|
|
|
2017-09-20 23:25:55 +02:00
|
|
|
|
/* URL for additional info */
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_Begin (NULL);
|
2019-10-07 20:17:29 +02:00
|
|
|
|
|
2019-12-27 21:10:39 +01:00
|
|
|
|
/* Label */
|
2019-12-27 15:45:19 +01:00
|
|
|
|
Frm_LabelColumn ("RT","WWW",Txt_URL);
|
2019-10-07 20:17:29 +02:00
|
|
|
|
|
2019-12-27 21:10:39 +01:00
|
|
|
|
/* Data */
|
2019-12-26 22:29:04 +01:00
|
|
|
|
HTM_TD_Begin ("class=\"DAT LT\"");
|
2019-11-04 12:25:48 +01:00
|
|
|
|
HTM_INPUT_URL ("URL",Prj->URL,false,
|
2019-11-27 00:27:42 +01:00
|
|
|
|
"class=\"TITLE_DESCRIPTION_WIDTH\"");
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2019-10-07 20:17:29 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_End ();
|
2017-09-18 01:06:51 +02:00
|
|
|
|
|
2017-09-20 23:25:55 +02:00
|
|
|
|
/* End table, send button and end box */
|
2017-09-17 18:55:02 +02:00
|
|
|
|
if (ItsANewProject)
|
2019-11-25 23:18:08 +01:00
|
|
|
|
Box_BoxTableWithButtonEnd (Btn_CREATE_BUTTON,Txt_Create_project);
|
2017-09-15 13:19:27 +02:00
|
|
|
|
else
|
2019-11-25 23:18:08 +01:00
|
|
|
|
Box_BoxTableWithButtonEnd (Btn_CONFIRM_BUTTON,Txt_Save_changes);
|
2017-09-15 13:19:27 +02:00
|
|
|
|
|
2017-10-01 11:57:25 +02:00
|
|
|
|
/* End data form */
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_EndForm ();
|
2017-09-15 13:19:27 +02:00
|
|
|
|
|
2017-10-01 11:57:25 +02:00
|
|
|
|
/***** End project box *****/
|
2019-10-25 22:48:34 +02:00
|
|
|
|
Box_BoxEnd ();
|
2017-09-15 13:19:27 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-09-19 01:12:05 +02:00
|
|
|
|
/*****************************************************************************/
|
2017-09-20 23:25:55 +02:00
|
|
|
|
/************************ Show text row about a project **********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Prj_EditOneProjectTxtArea (const char *Id,
|
2017-09-23 15:39:21 +02:00
|
|
|
|
const char *Label,char *TxtField,
|
2019-10-14 02:21:41 +02:00
|
|
|
|
unsigned NumRows,bool Required)
|
2017-09-20 23:25:55 +02:00
|
|
|
|
{
|
2019-02-22 21:47:50 +01:00
|
|
|
|
extern const char *The_ClassFormInBox[The_NUM_THEMES];
|
2017-09-20 23:25:55 +02:00
|
|
|
|
|
2019-12-27 21:10:39 +01:00
|
|
|
|
/***** Description *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_Begin (NULL);
|
2019-10-07 20:17:29 +02:00
|
|
|
|
|
2019-12-27 21:10:39 +01:00
|
|
|
|
/* Label */
|
2019-12-27 15:45:19 +01:00
|
|
|
|
Frm_LabelColumn ("RT",Id,Label);
|
2019-10-07 20:17:29 +02:00
|
|
|
|
|
2019-12-27 21:10:39 +01:00
|
|
|
|
/* Data */
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"LT\"");
|
2019-11-27 00:27:42 +01:00
|
|
|
|
HTM_TEXTAREA_Begin ("id=\"%s\" name=\"%s\" rows=\"%u\"%s"
|
|
|
|
|
" class=\"TITLE_DESCRIPTION_WIDTH\"",
|
2019-10-31 17:42:05 +01:00
|
|
|
|
Id,Id,NumRows,Required ? " required=\"required\"" :
|
|
|
|
|
"");
|
2019-11-10 12:36:37 +01:00
|
|
|
|
HTM_Txt (TxtField);
|
2019-10-31 17:42:05 +01:00
|
|
|
|
HTM_TEXTAREA_End ();
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2019-10-07 20:17:29 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_End ();
|
2017-09-20 23:25:55 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2017-09-19 01:12:05 +02:00
|
|
|
|
/*** Allocate memory for those parameters of a project with a lot of text ****/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2017-10-07 12:28:19 +02:00
|
|
|
|
void Prj_AllocMemProject (struct Project *Prj)
|
2017-09-19 01:12:05 +02:00
|
|
|
|
{
|
2018-10-08 12:37:29 +02:00
|
|
|
|
if ((Prj->Description = (char *) malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
|
2018-10-18 20:06:54 +02:00
|
|
|
|
Lay_NotEnoughMemoryExit ();
|
2017-09-19 01:12:05 +02:00
|
|
|
|
|
2018-10-08 12:37:29 +02:00
|
|
|
|
if ((Prj->Knowledge = (char *) malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
|
2018-10-18 20:06:54 +02:00
|
|
|
|
Lay_NotEnoughMemoryExit ();
|
2017-09-19 01:12:05 +02:00
|
|
|
|
|
2018-10-08 12:37:29 +02:00
|
|
|
|
if ((Prj->Materials = (char *) malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
|
2018-10-18 20:06:54 +02:00
|
|
|
|
Lay_NotEnoughMemoryExit ();
|
2017-09-19 01:12:05 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/****** Free memory of those parameters of a project with a lot of text ******/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2017-10-07 12:28:19 +02:00
|
|
|
|
void Prj_FreeMemProject (struct Project *Prj)
|
2017-09-19 01:12:05 +02:00
|
|
|
|
{
|
|
|
|
|
if (Prj->Description)
|
|
|
|
|
{
|
2019-11-06 19:45:20 +01:00
|
|
|
|
free (Prj->Description);
|
2017-09-19 01:12:05 +02:00
|
|
|
|
Prj->Description = NULL;
|
|
|
|
|
}
|
|
|
|
|
if (Prj->Knowledge)
|
|
|
|
|
{
|
2019-11-06 19:45:20 +01:00
|
|
|
|
free (Prj->Knowledge);
|
2017-09-19 01:12:05 +02:00
|
|
|
|
Prj->Knowledge = NULL;
|
|
|
|
|
}
|
|
|
|
|
if (Prj->Materials)
|
|
|
|
|
{
|
2019-11-06 19:45:20 +01:00
|
|
|
|
free (Prj->Materials);
|
2017-09-19 01:12:05 +02:00
|
|
|
|
Prj->Materials = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-15 13:19:27 +02:00
|
|
|
|
/*****************************************************************************/
|
2017-09-17 16:58:09 +02:00
|
|
|
|
/******************** Receive form to create a new project *******************/
|
2017-09-15 13:19:27 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Prj_RecFormProject (void)
|
|
|
|
|
{
|
2017-09-17 16:58:09 +02:00
|
|
|
|
extern const char *Txt_You_must_specify_the_title_of_the_project;
|
|
|
|
|
extern const char *Txt_Created_new_project_X;
|
|
|
|
|
extern const char *Txt_The_project_has_been_modified;
|
2017-09-19 09:35:36 +02:00
|
|
|
|
struct Project Prj; // Project data received from form
|
2017-09-17 18:55:02 +02:00
|
|
|
|
bool ItsANewProject;
|
2017-09-25 00:22:54 +02:00
|
|
|
|
bool ICanEditProject;
|
2017-09-17 18:55:02 +02:00
|
|
|
|
bool NewProjectIsCorrect = true;
|
2017-09-19 01:12:05 +02:00
|
|
|
|
|
|
|
|
|
/***** Allocate memory for the project *****/
|
2017-09-19 09:35:36 +02:00
|
|
|
|
Prj_AllocMemProject (&Prj);
|
2017-09-15 13:19:27 +02:00
|
|
|
|
|
2017-10-01 13:42:56 +02:00
|
|
|
|
/***** Get parameters *****/
|
2017-10-10 01:26:45 +02:00
|
|
|
|
Prj_GetParams ();
|
2017-10-07 18:11:49 +02:00
|
|
|
|
ItsANewProject = ((Prj.PrjCod = Prj_GetParamPrjCod ()) < 0);
|
2017-09-15 13:19:27 +02:00
|
|
|
|
|
2017-09-17 18:55:02 +02:00
|
|
|
|
if (ItsANewProject)
|
2017-09-25 00:22:54 +02:00
|
|
|
|
{
|
2017-09-19 09:35:36 +02:00
|
|
|
|
/* Reset project data */
|
|
|
|
|
Prj_ResetProject (&Prj);
|
2017-09-25 00:22:54 +02:00
|
|
|
|
|
|
|
|
|
ICanEditProject = true;
|
|
|
|
|
}
|
2017-09-15 13:19:27 +02:00
|
|
|
|
else
|
2017-09-25 00:22:54 +02:00
|
|
|
|
{
|
2017-09-19 09:35:36 +02:00
|
|
|
|
/* Get data of the project from database */
|
|
|
|
|
Prj_GetDataOfProjectByCod (&Prj);
|
2017-09-15 13:19:27 +02:00
|
|
|
|
|
2019-04-18 11:10:39 +02:00
|
|
|
|
ICanEditProject = Prj_CheckIfICanEditProject (&Prj);
|
2017-09-25 00:22:54 +02:00
|
|
|
|
}
|
2017-09-15 13:19:27 +02:00
|
|
|
|
|
2017-09-25 00:22:54 +02:00
|
|
|
|
if (ICanEditProject)
|
|
|
|
|
{
|
|
|
|
|
/* Get project title */
|
|
|
|
|
Par_GetParToText ("Title",Prj.Title,Prj_MAX_BYTES_PROJECT_TITLE);
|
2017-09-22 00:26:14 +02:00
|
|
|
|
|
2017-09-25 00:22:54 +02:00
|
|
|
|
/* Get department */
|
2017-10-10 12:37:09 +02:00
|
|
|
|
Prj.DptCod = Par_GetParToLong (Dpt_PARAM_DPT_COD_NAME);
|
2017-09-15 13:19:27 +02:00
|
|
|
|
|
2019-10-25 22:48:34 +02:00
|
|
|
|
/* Get whether the project is assigned */
|
|
|
|
|
Prj.Assigned = (Par_GetParToBool ("Assigned")) ? Prj_ASSIGNED :
|
|
|
|
|
Prj_NONASSIG;
|
2017-10-01 18:44:50 +02:00
|
|
|
|
|
2017-10-02 02:19:14 +02:00
|
|
|
|
/* Get number of students */
|
|
|
|
|
Prj.NumStds = (unsigned)
|
|
|
|
|
Par_GetParToUnsignedLong ("NumStds",
|
|
|
|
|
0,
|
|
|
|
|
UINT_MAX,
|
|
|
|
|
1);
|
|
|
|
|
|
2017-10-02 01:16:10 +02:00
|
|
|
|
/* Get status */
|
2017-10-02 19:34:31 +02:00
|
|
|
|
Prj.Proposal = (Prj_Proposal_t)
|
|
|
|
|
Par_GetParToUnsignedLong ("Proposal",
|
|
|
|
|
0,
|
|
|
|
|
Prj_NUM_PROPOSAL_TYPES - 1,
|
|
|
|
|
(unsigned long) Prj_PROPOSAL_DEFAULT);
|
2017-10-02 01:16:10 +02:00
|
|
|
|
|
2017-09-25 00:22:54 +02:00
|
|
|
|
/* Get project description, required knowledge and required materials */
|
|
|
|
|
Par_GetParToHTML ("Description",Prj.Description,Cns_MAX_BYTES_TEXT); // Store in HTML format (not rigorous)
|
|
|
|
|
Par_GetParToHTML ("Knowledge" ,Prj.Knowledge ,Cns_MAX_BYTES_TEXT); // Store in HTML format (not rigorous)
|
|
|
|
|
Par_GetParToHTML ("Materials" ,Prj.Materials ,Cns_MAX_BYTES_TEXT); // Store in HTML format (not rigorous)
|
2017-09-18 17:26:20 +02:00
|
|
|
|
|
2017-09-25 00:22:54 +02:00
|
|
|
|
/* Get degree WWW */
|
|
|
|
|
Par_GetParToText ("URL",Prj.URL,Cns_MAX_BYTES_WWW);
|
2017-09-19 14:05:02 +02:00
|
|
|
|
|
2017-09-25 00:22:54 +02:00
|
|
|
|
/***** Check if title is correct *****/
|
|
|
|
|
if (!Prj.Title[0]) // If there is not a project title
|
2017-09-15 13:19:27 +02:00
|
|
|
|
{
|
2017-09-25 00:22:54 +02:00
|
|
|
|
NewProjectIsCorrect = false;
|
2019-02-16 18:25:41 +01:00
|
|
|
|
Ale_ShowAlert (Ale_WARNING,Txt_You_must_specify_the_title_of_the_project);
|
2017-09-15 13:19:27 +02:00
|
|
|
|
}
|
2017-09-25 00:22:54 +02:00
|
|
|
|
|
|
|
|
|
/***** Create a new project or update an existing one *****/
|
|
|
|
|
if (NewProjectIsCorrect)
|
2017-09-17 23:37:03 +02:00
|
|
|
|
{
|
2017-09-25 00:22:54 +02:00
|
|
|
|
if (ItsANewProject)
|
|
|
|
|
{
|
2017-10-07 22:08:38 +02:00
|
|
|
|
/* Create project */
|
2017-09-25 00:22:54 +02:00
|
|
|
|
Prj_CreateProject (&Prj); // Add new project to database
|
2017-09-17 23:37:03 +02:00
|
|
|
|
|
2017-10-07 22:08:38 +02:00
|
|
|
|
/* Write success message */
|
2019-02-16 18:25:41 +01:00
|
|
|
|
Ale_ShowAlert (Ale_SUCCESS,Txt_Created_new_project_X,
|
|
|
|
|
Prj.Title);
|
2017-09-25 00:22:54 +02:00
|
|
|
|
}
|
|
|
|
|
else if (NewProjectIsCorrect)
|
|
|
|
|
{
|
2017-10-07 22:08:38 +02:00
|
|
|
|
/* Update project */
|
2017-09-25 00:22:54 +02:00
|
|
|
|
Prj_UpdateProject (&Prj);
|
|
|
|
|
|
2017-10-07 22:08:38 +02:00
|
|
|
|
/* Write success message */
|
2019-02-16 18:25:41 +01:00
|
|
|
|
Ale_ShowAlert (Ale_SUCCESS,Txt_The_project_has_been_modified);
|
2017-09-25 00:22:54 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
2017-09-25 00:33:57 +02:00
|
|
|
|
Prj_PutFormProject (&Prj,ItsANewProject);
|
|
|
|
|
|
2017-10-01 13:42:56 +02:00
|
|
|
|
/***** Show again form to edit project *****/
|
|
|
|
|
Prj_RequestCreatOrEditPrj (Prj.PrjCod);
|
2017-09-15 13:19:27 +02:00
|
|
|
|
}
|
|
|
|
|
else
|
2019-10-26 01:56:36 +02:00
|
|
|
|
Lay_NoPermissionExit ();
|
2017-09-19 01:12:05 +02:00
|
|
|
|
|
|
|
|
|
/***** Free memory of the project *****/
|
2017-09-19 09:35:36 +02:00
|
|
|
|
Prj_FreeMemProject (&Prj);
|
2017-09-15 13:19:27 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2017-09-17 16:58:09 +02:00
|
|
|
|
/************************** Create a new project *****************************/
|
2017-09-15 13:19:27 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2017-09-19 01:12:05 +02:00
|
|
|
|
static void Prj_CreateProject (struct Project *Prj)
|
2017-09-15 13:19:27 +02:00
|
|
|
|
{
|
2017-10-07 22:08:38 +02:00
|
|
|
|
/***** Set dates to now *****/
|
|
|
|
|
Prj->CreatTime =
|
|
|
|
|
Prj->ModifTime = Gbl.StartExecutionTimeUTC;
|
|
|
|
|
|
2017-09-15 13:19:27 +02:00
|
|
|
|
/***** Create a new project *****/
|
2018-11-03 01:45:36 +01:00
|
|
|
|
Prj->PrjCod =
|
|
|
|
|
DB_QueryINSERTandReturnCode ("can not create new project",
|
|
|
|
|
"INSERT INTO projects"
|
2019-10-25 22:48:34 +02:00
|
|
|
|
" (CrsCod,DptCod,Hidden,Assigned,NumStds,Proposal,"
|
2018-11-03 01:45:36 +01:00
|
|
|
|
"CreatTime,ModifTime,"
|
|
|
|
|
"Title,Description,Knowledge,Materials,URL)"
|
|
|
|
|
" VALUES"
|
|
|
|
|
" (%ld,%ld,'%c','%c',%u,'%s',"
|
|
|
|
|
"FROM_UNIXTIME(%ld),FROM_UNIXTIME(%ld),"
|
|
|
|
|
"'%s','%s','%s','%s','%s')",
|
2019-04-04 10:45:15 +02:00
|
|
|
|
Gbl.Hierarchy.Crs.CrsCod,
|
2018-11-03 01:45:36 +01:00
|
|
|
|
Prj->DptCod,
|
|
|
|
|
Prj->Hidden == Prj_HIDDEN ? 'Y' :
|
|
|
|
|
'N',
|
2019-10-25 01:15:11 +02:00
|
|
|
|
Prj->Assigned == Prj_ASSIGNED ? 'Y' :
|
2019-10-25 22:48:34 +02:00
|
|
|
|
'N',
|
2018-11-03 01:45:36 +01:00
|
|
|
|
Prj->NumStds,
|
|
|
|
|
Prj_Proposal_DB[Prj->Proposal],
|
|
|
|
|
Prj->CreatTime,
|
|
|
|
|
Prj->ModifTime,
|
|
|
|
|
Prj->Title,
|
|
|
|
|
Prj->Description,
|
|
|
|
|
Prj->Knowledge,
|
|
|
|
|
Prj->Materials,
|
|
|
|
|
Prj->URL);
|
2017-09-19 18:13:52 +02:00
|
|
|
|
|
|
|
|
|
/***** Insert creator as first tutor *****/
|
2018-11-02 19:37:11 +01:00
|
|
|
|
DB_QueryINSERT ("can not add tutor",
|
|
|
|
|
"INSERT INTO prj_usr"
|
|
|
|
|
" (PrjCod,RoleInProject,UsrCod)"
|
|
|
|
|
" VALUES"
|
|
|
|
|
" (%ld,%u,%ld)",
|
|
|
|
|
Prj->PrjCod,
|
|
|
|
|
(unsigned) Prj_ROLE_TUT,
|
|
|
|
|
Gbl.Usrs.Me.UsrDat.UsrCod);
|
2017-10-08 16:12:58 +02:00
|
|
|
|
|
|
|
|
|
/***** Flush cache *****/
|
2019-04-11 15:24:05 +02:00
|
|
|
|
Prj_FlushCacheMyRolesInProject ();
|
2017-09-15 13:19:27 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2017-09-17 16:58:09 +02:00
|
|
|
|
/*********************** Update an existing project **************************/
|
2017-09-15 13:19:27 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2017-09-19 01:12:05 +02:00
|
|
|
|
static void Prj_UpdateProject (struct Project *Prj)
|
2017-09-15 13:19:27 +02:00
|
|
|
|
{
|
2017-10-07 22:08:38 +02:00
|
|
|
|
/***** Adjust date of last edition to now *****/
|
|
|
|
|
Prj->ModifTime = Gbl.StartExecutionTimeUTC;
|
|
|
|
|
|
2017-09-15 13:19:27 +02:00
|
|
|
|
/***** Update the data of the project *****/
|
2018-11-03 12:16:40 +01:00
|
|
|
|
DB_QueryUPDATE ("can not update project",
|
|
|
|
|
"UPDATE projects"
|
|
|
|
|
" SET DptCod=%ld,"
|
|
|
|
|
"Hidden='%c',"
|
2019-10-25 22:48:34 +02:00
|
|
|
|
"Assigned='%c',"
|
2018-11-03 12:16:40 +01:00
|
|
|
|
"NumStds=%u,"
|
|
|
|
|
"Proposal='%s',"
|
|
|
|
|
"ModifTime=FROM_UNIXTIME(%ld),"
|
|
|
|
|
"Title='%s',"
|
|
|
|
|
"Description='%s',"
|
|
|
|
|
"Knowledge='%s',"
|
|
|
|
|
"Materials='%s',"
|
|
|
|
|
"URL='%s'"
|
|
|
|
|
" WHERE PrjCod=%ld AND CrsCod=%ld",
|
|
|
|
|
Prj->DptCod,
|
|
|
|
|
Prj->Hidden == Prj_HIDDEN ? 'Y' :
|
|
|
|
|
'N',
|
2019-10-25 01:15:11 +02:00
|
|
|
|
Prj->Assigned == Prj_ASSIGNED ? 'Y' :
|
2019-10-25 22:48:34 +02:00
|
|
|
|
'N',
|
2018-11-03 12:16:40 +01:00
|
|
|
|
Prj->NumStds,
|
|
|
|
|
Prj_Proposal_DB[Prj->Proposal],
|
|
|
|
|
Prj->ModifTime,
|
|
|
|
|
Prj->Title,
|
|
|
|
|
Prj->Description,
|
|
|
|
|
Prj->Knowledge,
|
|
|
|
|
Prj->Materials,
|
|
|
|
|
Prj->URL,
|
2019-04-04 10:45:15 +02:00
|
|
|
|
Prj->PrjCod,Gbl.Hierarchy.Crs.CrsCod);
|
2017-09-15 13:19:27 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-10-25 22:48:34 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************ Can I configure all projects? **********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static bool Prj_CheckIfICanConfigAllProjects (void)
|
|
|
|
|
{
|
|
|
|
|
switch (Gbl.Usrs.Me.Role.Logged)
|
|
|
|
|
{
|
|
|
|
|
case Rol_TCH:
|
|
|
|
|
case Rol_SYS_ADM:
|
|
|
|
|
return true;
|
|
|
|
|
default:
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************** Configuration of all projects ************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Prj_ShowFormConfig (void)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Hlp_ASSESSMENT_Projects;
|
|
|
|
|
extern const char *The_ClassFormInBox[The_NUM_THEMES];
|
2019-10-26 01:56:36 +02:00
|
|
|
|
extern const char *Txt_Configure_projects;
|
2019-10-25 22:48:34 +02:00
|
|
|
|
extern const char *Txt_Editable;
|
|
|
|
|
extern const char *Txt_Editable_by_non_editing_teachers;
|
|
|
|
|
extern const char *Txt_Save_changes;
|
|
|
|
|
|
|
|
|
|
/***** Read projects configuration from database *****/
|
|
|
|
|
Prj_GetConfigPrjFromDB ();
|
|
|
|
|
|
2019-10-26 02:19:42 +02:00
|
|
|
|
/***** Begin box *****/
|
2019-10-26 01:56:36 +02:00
|
|
|
|
Box_BoxBegin (NULL,Txt_Configure_projects,Prj_PutIconsListProjects,
|
2019-10-25 22:48:34 +02:00
|
|
|
|
Hlp_ASSESSMENT_Projects,Box_NOT_CLOSABLE);
|
|
|
|
|
|
|
|
|
|
/***** Begin form *****/
|
|
|
|
|
Frm_StartForm (ActRcvCfgPrj);
|
|
|
|
|
|
|
|
|
|
/***** Projects are editable by non-editing teachers? *****/
|
|
|
|
|
HTM_TABLE_BeginCenterPadding (2);
|
|
|
|
|
HTM_TR_Begin (NULL);
|
|
|
|
|
|
2019-12-27 21:10:39 +01:00
|
|
|
|
/* Label */
|
2019-12-27 15:45:19 +01:00
|
|
|
|
Frm_LabelColumn ("RT","Editable",Txt_Editable);
|
2019-10-25 22:48:34 +02:00
|
|
|
|
|
2019-12-27 21:10:39 +01:00
|
|
|
|
/* Data */
|
2019-10-25 22:48:34 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"LT\"");
|
2019-11-04 20:41:35 +01:00
|
|
|
|
HTM_INPUT_CHECKBOX ("Editable",false,
|
|
|
|
|
"id=\"Editable\" value=\"Y\"%s",
|
|
|
|
|
Gbl.Prjs.Config.Editable ? " checked=\"checked\"" : "");
|
2019-11-10 12:36:37 +01:00
|
|
|
|
HTM_Txt (Txt_Editable_by_non_editing_teachers);
|
2019-10-25 22:48:34 +02:00
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
HTM_TR_End ();
|
|
|
|
|
|
|
|
|
|
HTM_TABLE_End ();
|
|
|
|
|
|
|
|
|
|
/***** Send button *****/
|
|
|
|
|
Btn_PutConfirmButton (Txt_Save_changes);
|
|
|
|
|
|
|
|
|
|
/***** End form *****/
|
|
|
|
|
Frm_EndForm ();
|
|
|
|
|
|
|
|
|
|
/***** End box *****/
|
|
|
|
|
Box_BoxEnd ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************** Get configuration of projects for current course *************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Prj_GetConfigPrjFromDB (void)
|
|
|
|
|
{
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
|
|
|
|
unsigned long NumRows;
|
|
|
|
|
|
|
|
|
|
/***** Get configuration of projects for current course from database *****/
|
|
|
|
|
NumRows = DB_QuerySELECT (&mysql_res,"can not get configuration of test",
|
|
|
|
|
"SELECT Editable" // row[0]
|
|
|
|
|
" FROM prj_config WHERE CrsCod=%ld",
|
|
|
|
|
Gbl.Hierarchy.Crs.CrsCod);
|
|
|
|
|
|
|
|
|
|
if (NumRows == 0)
|
|
|
|
|
Gbl.Prjs.Config.Editable = Prj_EDITABLE_DEFAULT;
|
|
|
|
|
else // NumRows == 1
|
|
|
|
|
{
|
|
|
|
|
/***** Get configuration *****/
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
|
|
|
|
Prj_GetConfigFromRow (row);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************ Get configuration values from a database table row *************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Prj_GetConfigFromRow (MYSQL_ROW row)
|
|
|
|
|
{
|
|
|
|
|
/***** Get whether project are visible via plugins or not *****/
|
|
|
|
|
Gbl.Prjs.Config.Editable = (row[0][0] == 'Y');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************ Receive configuration of projects for current course ***********/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Prj_ReceiveConfigPrj (void)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_The_configuration_of_the_projects_has_been_updated;
|
|
|
|
|
|
|
|
|
|
/***** Get whether projects are editable by non-editing teachers or not *****/
|
|
|
|
|
Gbl.Prjs.Config.Editable = Prj_GetEditableFromForm ();
|
|
|
|
|
|
|
|
|
|
/***** Update database *****/
|
|
|
|
|
DB_QueryREPLACE ("can not save configuration of projects",
|
|
|
|
|
"REPLACE INTO prj_config"
|
|
|
|
|
" (CrsCod,Editable)"
|
|
|
|
|
" VALUES"
|
|
|
|
|
" (%ld,'%c')",
|
|
|
|
|
Gbl.Hierarchy.Crs.CrsCod,
|
|
|
|
|
Gbl.Prjs.Config.Editable ? 'Y' :
|
|
|
|
|
'N');
|
|
|
|
|
|
|
|
|
|
/***** Show confirmation message *****/
|
|
|
|
|
Ale_ShowAlert (Ale_SUCCESS,Txt_The_configuration_of_the_projects_has_been_updated);
|
|
|
|
|
|
|
|
|
|
/***** Show again the form to configure projects *****/
|
|
|
|
|
Prj_ShowFormConfig ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/****** Get if projects are editable by non-editing teachers from form *******/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static bool Prj_GetEditableFromForm (void)
|
|
|
|
|
{
|
|
|
|
|
return Par_GetParToBool ("Editable");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/****** Put icons to request locking/unlocking edition of all projects *******/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Prj_PutIconsToLockUnlockAllProjects (void)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Lock_editing;
|
|
|
|
|
extern const char *Txt_Unlock_editing;
|
|
|
|
|
|
|
|
|
|
/***** Put icon to lock all projects *****/
|
|
|
|
|
Lay_PutContextualLinkOnlyIcon (ActReqLckAllPrj,NULL,Prj_PutCurrentParams,
|
|
|
|
|
"lock.svg",
|
|
|
|
|
Txt_Lock_editing);
|
|
|
|
|
|
|
|
|
|
/***** Put icon to unlock all projects *****/
|
|
|
|
|
Lay_PutContextualLinkOnlyIcon (ActReqUnlAllPrj,NULL,Prj_PutCurrentParams,
|
|
|
|
|
"unlock.svg",
|
|
|
|
|
Txt_Unlock_editing);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2019-11-13 09:49:52 +01:00
|
|
|
|
/********** Request locking/unlocking edition of selected projects ***********/
|
2019-10-25 22:48:34 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2019-11-14 09:39:21 +01:00
|
|
|
|
void Prj_ReqLockSelectedPrjsEdition (void)
|
2019-10-25 22:48:34 +02:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Lock_editing;
|
|
|
|
|
extern const char *Txt_Do_you_want_to_lock_the_editing_of_the_X_selected_projects;
|
|
|
|
|
extern const char *Txt_No_projects;
|
|
|
|
|
|
|
|
|
|
/***** Get parameters *****/
|
|
|
|
|
Prj_GetParams ();
|
|
|
|
|
|
|
|
|
|
/***** Show question and button to lock all selected projects *****/
|
|
|
|
|
if (Prj_CheckIfICanConfigAllProjects ())
|
|
|
|
|
{
|
|
|
|
|
/* Get list of projects */
|
|
|
|
|
Prj_GetListProjects ();
|
|
|
|
|
|
|
|
|
|
/* Show question and button */
|
|
|
|
|
if (Gbl.Prjs.Num)
|
|
|
|
|
Ale_ShowAlertAndButton (ActLckAllPrj,NULL,NULL,Prj_PutCurrentParams,
|
|
|
|
|
Btn_REMOVE_BUTTON,Txt_Lock_editing,
|
|
|
|
|
Ale_QUESTION,Txt_Do_you_want_to_lock_the_editing_of_the_X_selected_projects,
|
|
|
|
|
Gbl.Prjs.Num);
|
|
|
|
|
else // No projects found
|
|
|
|
|
Ale_ShowAlert (Ale_INFO,Txt_No_projects);
|
|
|
|
|
|
|
|
|
|
/* Free list of projects */
|
|
|
|
|
Prj_FreeListProjects ();
|
|
|
|
|
}
|
|
|
|
|
else
|
2019-10-26 01:56:36 +02:00
|
|
|
|
Lay_NoPermissionExit ();
|
2019-10-25 22:48:34 +02:00
|
|
|
|
|
|
|
|
|
/***** Show projects again *****/
|
2019-11-15 03:34:48 +01:00
|
|
|
|
Prj_ShowProjects ();
|
2019-10-25 22:48:34 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-11-14 09:39:21 +01:00
|
|
|
|
void Prj_ReqUnloSelectedPrjsEdition (void)
|
2019-10-25 22:48:34 +02:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Unlock_editing;
|
|
|
|
|
extern const char *Txt_Do_you_want_to_unlock_the_editing_of_the_X_selected_projects;
|
|
|
|
|
extern const char *Txt_No_projects;
|
|
|
|
|
|
|
|
|
|
/***** Get parameters *****/
|
|
|
|
|
Prj_GetParams ();
|
|
|
|
|
|
|
|
|
|
/***** Show question and button to unlock all selected projects *****/
|
|
|
|
|
if (Prj_CheckIfICanConfigAllProjects ())
|
|
|
|
|
{
|
|
|
|
|
/* Get list of projects */
|
|
|
|
|
Prj_GetListProjects ();
|
|
|
|
|
|
|
|
|
|
/* Show question and button */
|
|
|
|
|
if (Gbl.Prjs.Num)
|
|
|
|
|
Ale_ShowAlertAndButton (ActUnlAllPrj,NULL,NULL,Prj_PutCurrentParams,
|
|
|
|
|
Btn_CREATE_BUTTON,Txt_Unlock_editing,
|
|
|
|
|
Ale_QUESTION,Txt_Do_you_want_to_unlock_the_editing_of_the_X_selected_projects,
|
|
|
|
|
Gbl.Prjs.Num);
|
|
|
|
|
else // No projects found
|
|
|
|
|
Ale_ShowAlert (Ale_INFO,Txt_No_projects);
|
|
|
|
|
|
|
|
|
|
/* Free list of projects */
|
|
|
|
|
Prj_FreeListProjects ();
|
|
|
|
|
}
|
|
|
|
|
else
|
2019-10-26 01:56:36 +02:00
|
|
|
|
Lay_NoPermissionExit ();
|
2019-10-25 22:48:34 +02:00
|
|
|
|
|
|
|
|
|
/***** Show projects again *****/
|
2019-11-15 03:34:48 +01:00
|
|
|
|
Prj_ShowProjects ();
|
2019-10-25 22:48:34 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2019-11-13 09:49:52 +01:00
|
|
|
|
/***************** Lock/unlock edition of selected projects ******************/
|
2019-10-25 22:48:34 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2019-11-14 09:39:21 +01:00
|
|
|
|
void Prj_LockSelectedPrjsEdition (void)
|
2019-10-25 22:48:34 +02:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_No_projects;
|
|
|
|
|
unsigned NumPrj;
|
|
|
|
|
|
|
|
|
|
/***** Get parameters *****/
|
|
|
|
|
Prj_GetParams ();
|
|
|
|
|
|
|
|
|
|
/***** Lock all selected projects *****/
|
|
|
|
|
if (Prj_CheckIfICanConfigAllProjects ())
|
|
|
|
|
{
|
|
|
|
|
/* Get list of projects */
|
|
|
|
|
Prj_GetListProjects ();
|
|
|
|
|
|
|
|
|
|
/* Lock projects */
|
|
|
|
|
if (Gbl.Prjs.Num)
|
|
|
|
|
for (NumPrj = 0;
|
|
|
|
|
NumPrj < Gbl.Prjs.Num;
|
|
|
|
|
NumPrj++)
|
|
|
|
|
Prj_LockProjectEditionInDB (Gbl.Prjs.LstPrjCods[NumPrj]);
|
|
|
|
|
else // No projects found
|
|
|
|
|
Ale_ShowAlert (Ale_INFO,Txt_No_projects);
|
|
|
|
|
|
|
|
|
|
/* Free list of projects */
|
|
|
|
|
Prj_FreeListProjects ();
|
|
|
|
|
}
|
|
|
|
|
else
|
2019-10-26 01:56:36 +02:00
|
|
|
|
Lay_NoPermissionExit ();
|
2019-10-25 22:48:34 +02:00
|
|
|
|
|
|
|
|
|
/***** Show projects again *****/
|
2019-11-15 03:34:48 +01:00
|
|
|
|
Prj_ShowProjects ();
|
2019-10-25 22:48:34 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-11-14 09:39:21 +01:00
|
|
|
|
void Prj_UnloSelectedPrjsEdition (void)
|
2019-10-25 22:48:34 +02:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_No_projects;
|
|
|
|
|
unsigned NumPrj;
|
|
|
|
|
|
|
|
|
|
/***** Get parameters *****/
|
|
|
|
|
Prj_GetParams ();
|
|
|
|
|
|
|
|
|
|
/***** Unlock all selected projects *****/
|
|
|
|
|
if (Prj_CheckIfICanConfigAllProjects ())
|
|
|
|
|
{
|
|
|
|
|
/* Get list of projects */
|
|
|
|
|
Prj_GetListProjects ();
|
|
|
|
|
|
|
|
|
|
/* Unlock projects */
|
|
|
|
|
if (Gbl.Prjs.Num)
|
|
|
|
|
for (NumPrj = 0;
|
|
|
|
|
NumPrj < Gbl.Prjs.Num;
|
|
|
|
|
NumPrj++)
|
|
|
|
|
Prj_UnlockProjectEditionInDB (Gbl.Prjs.LstPrjCods[NumPrj]);
|
|
|
|
|
else // No projects found
|
|
|
|
|
Ale_ShowAlert (Ale_INFO,Txt_No_projects);
|
|
|
|
|
|
|
|
|
|
/* Free list of projects */
|
|
|
|
|
Prj_FreeListProjects ();
|
|
|
|
|
}
|
|
|
|
|
else
|
2019-10-26 01:56:36 +02:00
|
|
|
|
Lay_NoPermissionExit ();
|
2019-10-25 22:48:34 +02:00
|
|
|
|
|
|
|
|
|
/***** Show projects again *****/
|
2019-11-15 03:34:48 +01:00
|
|
|
|
Prj_ShowProjects ();
|
2019-10-25 22:48:34 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************** Form to lock/unlock project edition ********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Prj_FormLockUnlock (const struct Project *Prj)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_LOCKED_UNLOCKED[Prj_NUM_LOCKED_UNLOCKED];
|
|
|
|
|
char *OnSubmit;
|
|
|
|
|
/*
|
|
|
|
|
+---------------------+
|
|
|
|
|
| div (parent of form)|
|
|
|
|
|
| +-----------------+ |
|
|
|
|
|
| | this form | |
|
|
|
|
|
| | +-------------+ | |
|
|
|
|
|
| | | icon | | |
|
|
|
|
|
| | +-------------+ | |
|
|
|
|
|
| +-----------------+ |
|
|
|
|
|
+---------------------+
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/***** Form and icon to lock/unlock project edition *****/
|
|
|
|
|
/* Form with icon */
|
|
|
|
|
if (asprintf (&OnSubmit,"updateDivLockUnlockProject(this,"
|
|
|
|
|
"'act=%ld&ses=%s&PrjCod=%ld');"
|
|
|
|
|
" return false;", // return false is necessary to not submit form
|
|
|
|
|
Act_GetActCod (Prj_LockActions[Prj->Locked]),
|
|
|
|
|
Gbl.Session.Id,
|
|
|
|
|
Prj->PrjCod) < 0)
|
|
|
|
|
Lay_NotEnoughMemoryExit ();
|
|
|
|
|
Frm_StartFormOnSubmit (ActUnk,OnSubmit);
|
|
|
|
|
Ico_PutIconLink (Prj_LockIcons[Prj->Locked],Txt_LOCKED_UNLOCKED[Prj->Locked]);
|
|
|
|
|
Frm_EndForm ();
|
|
|
|
|
|
|
|
|
|
/* Free allocated memory for subquery */
|
2019-11-06 19:45:20 +01:00
|
|
|
|
free (OnSubmit);
|
2019-10-25 22:48:34 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********* Put icon to inform about locked/unlocked project edition **********/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Prj_PutIconOffLockedUnlocked (const struct Project *Prj)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_LOCKED_UNLOCKED[Prj_NUM_LOCKED_UNLOCKED];
|
|
|
|
|
|
|
|
|
|
/***** Icon to inform about locked/unlocked project edition *****/
|
|
|
|
|
Ico_PutIconOff (Prj_LockIcons[Prj->Locked],Txt_LOCKED_UNLOCKED[Prj->Locked]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************** Lock edition of a project ************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Prj_LockProjectEdition (void)
|
|
|
|
|
{
|
|
|
|
|
struct Project Prj;
|
|
|
|
|
|
|
|
|
|
/***** Allocate memory for the project *****/
|
|
|
|
|
Prj_AllocMemProject (&Prj);
|
|
|
|
|
|
|
|
|
|
/***** Get parameters *****/
|
|
|
|
|
Prj_GetParams ();
|
|
|
|
|
if ((Prj.PrjCod = Prj_GetParamPrjCod ()) < 0)
|
|
|
|
|
Lay_ShowErrorAndExit ("Code of project is missing.");
|
|
|
|
|
|
|
|
|
|
/***** Get data of the project from database *****/
|
|
|
|
|
Prj_GetDataOfProjectByCod (&Prj);
|
|
|
|
|
|
|
|
|
|
if (Prj_CheckIfICanEditProject (&Prj))
|
|
|
|
|
{
|
|
|
|
|
/***** Lock project edition *****/
|
|
|
|
|
Prj_LockProjectEditionInDB (Prj.PrjCod);
|
|
|
|
|
Prj.Locked = Prj_LOCKED;
|
|
|
|
|
|
|
|
|
|
/***** Show updated form and icon *****/
|
|
|
|
|
Prj_FormLockUnlock (&Prj);
|
|
|
|
|
}
|
|
|
|
|
else
|
2019-10-26 01:56:36 +02:00
|
|
|
|
Lay_NoPermissionExit ();
|
2019-10-25 22:48:34 +02:00
|
|
|
|
|
|
|
|
|
/***** Free memory of the project *****/
|
|
|
|
|
Prj_FreeMemProject (&Prj);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void Prj_LockProjectEditionInDB (long PrjCod)
|
|
|
|
|
{
|
|
|
|
|
DB_QueryUPDATE ("can not lock project edition",
|
|
|
|
|
"UPDATE projects SET Locked='Y'"
|
|
|
|
|
" WHERE PrjCod=%ld AND CrsCod=%ld",
|
|
|
|
|
PrjCod,Gbl.Hierarchy.Crs.CrsCod);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************* Unlock edition of a project ***********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2019-11-14 09:39:21 +01:00
|
|
|
|
void Prj_UnloProjectEdition (void)
|
2019-10-25 22:48:34 +02:00
|
|
|
|
{
|
|
|
|
|
struct Project Prj;
|
|
|
|
|
|
|
|
|
|
/***** Allocate memory for the project *****/
|
|
|
|
|
Prj_AllocMemProject (&Prj);
|
|
|
|
|
|
|
|
|
|
/***** Get parameters *****/
|
|
|
|
|
Prj_GetParams ();
|
|
|
|
|
if ((Prj.PrjCod = Prj_GetParamPrjCod ()) < 0)
|
|
|
|
|
Lay_ShowErrorAndExit ("Code of project is missing.");
|
|
|
|
|
|
|
|
|
|
/***** Get data of the project from database *****/
|
|
|
|
|
Prj_GetDataOfProjectByCod (&Prj);
|
|
|
|
|
|
|
|
|
|
if (Prj_CheckIfICanEditProject (&Prj))
|
|
|
|
|
{
|
|
|
|
|
/***** Unlock project edition *****/
|
|
|
|
|
Prj_UnlockProjectEditionInDB (Prj.PrjCod);
|
|
|
|
|
Prj.Locked = Prj_UNLOCKED;
|
|
|
|
|
|
|
|
|
|
/***** Show updated form and icon *****/
|
|
|
|
|
Prj_FormLockUnlock (&Prj);
|
|
|
|
|
}
|
|
|
|
|
else
|
2019-10-26 01:56:36 +02:00
|
|
|
|
Lay_NoPermissionExit ();
|
2019-10-25 22:48:34 +02:00
|
|
|
|
|
|
|
|
|
/***** Free memory of the project *****/
|
|
|
|
|
Prj_FreeMemProject (&Prj);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void Prj_UnlockProjectEditionInDB (long PrjCod)
|
|
|
|
|
{
|
|
|
|
|
DB_QueryUPDATE ("can not lock project edition",
|
|
|
|
|
"UPDATE projects SET Locked='N'"
|
|
|
|
|
" WHERE PrjCod=%ld AND CrsCod=%ld",
|
|
|
|
|
PrjCod,Gbl.Hierarchy.Crs.CrsCod);
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-15 13:19:27 +02:00
|
|
|
|
/*****************************************************************************/
|
2017-09-24 22:35:18 +02:00
|
|
|
|
/******************** Remove all the projects in a course ********************/
|
2017-09-15 13:19:27 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Prj_RemoveCrsProjects (long CrsCod)
|
|
|
|
|
{
|
2017-09-24 22:35:18 +02:00
|
|
|
|
/***** Remove users in projects of the course *****/
|
2018-11-02 22:00:31 +01:00
|
|
|
|
DB_QueryDELETE ("can not remove all the projects of a course",
|
|
|
|
|
"DELETE FROM prj_usr USING projects,prj_usr"
|
|
|
|
|
" WHERE projects.CrsCod=%ld"
|
|
|
|
|
" AND projects.PrjCod=prj_usr.PrjCod",
|
|
|
|
|
CrsCod);
|
2017-09-15 13:19:27 +02:00
|
|
|
|
|
2017-10-08 16:12:58 +02:00
|
|
|
|
/***** Flush cache *****/
|
2019-04-11 15:24:05 +02:00
|
|
|
|
Prj_FlushCacheMyRolesInProject ();
|
2017-10-08 16:12:58 +02:00
|
|
|
|
|
2019-10-26 01:11:09 +02:00
|
|
|
|
/***** Remove configuration of projects in the course *****/
|
|
|
|
|
DB_QueryDELETE ("can not remove configuration of projects of a course",
|
|
|
|
|
"DELETE FROM prj_config WHERE CrsCod=%ld",
|
|
|
|
|
CrsCod);
|
|
|
|
|
|
2017-09-15 13:19:27 +02:00
|
|
|
|
/***** Remove projects *****/
|
2018-11-02 22:00:31 +01:00
|
|
|
|
DB_QueryDELETE ("can not remove all the projects of a course",
|
|
|
|
|
"DELETE FROM projects WHERE CrsCod=%ld",
|
|
|
|
|
CrsCod);
|
2017-09-15 13:19:27 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-09-24 22:35:18 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************* Remove user from all his/her projects *******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Prj_RemoveUsrFromProjects (long UsrCod)
|
|
|
|
|
{
|
2018-10-10 14:03:06 +02:00
|
|
|
|
bool ItsMe;
|
2017-09-24 22:35:18 +02:00
|
|
|
|
|
|
|
|
|
/***** Remove user from projects *****/
|
2018-11-02 22:00:31 +01:00
|
|
|
|
DB_QueryDELETE ("can not remove user from projects",
|
|
|
|
|
"DELETE FROM prj_usr WHERE UsrCod=%ld",
|
|
|
|
|
UsrCod);
|
2017-10-08 16:12:58 +02:00
|
|
|
|
|
|
|
|
|
/***** Flush cache *****/
|
2018-10-10 23:56:42 +02:00
|
|
|
|
ItsMe = Usr_ItsMe (UsrCod);
|
2018-10-10 14:03:06 +02:00
|
|
|
|
if (ItsMe)
|
2019-04-11 15:24:05 +02:00
|
|
|
|
Prj_FlushCacheMyRolesInProject ();
|
2017-09-24 22:35:18 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-09-15 13:19:27 +02:00
|
|
|
|
/*****************************************************************************/
|
2017-09-17 16:58:09 +02:00
|
|
|
|
/******************** Get number of courses with projects ********************/
|
2017-09-15 13:19:27 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
// Returns the number of courses with projects
|
|
|
|
|
// in this location (all the platform, current degree or current course)
|
|
|
|
|
|
2019-04-03 20:57:04 +02:00
|
|
|
|
unsigned Prj_GetNumCoursesWithProjects (Hie_Level_t Scope)
|
2017-09-15 13:19:27 +02:00
|
|
|
|
{
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
|
|
|
|
unsigned NumCourses;
|
|
|
|
|
|
|
|
|
|
/***** Get number of courses with projects from database *****/
|
|
|
|
|
switch (Scope)
|
|
|
|
|
{
|
2019-04-03 20:57:04 +02:00
|
|
|
|
case Hie_SYS:
|
2018-11-01 19:23:52 +01:00
|
|
|
|
DB_QuerySELECT (&mysql_res,"can not get number of courses with projects",
|
|
|
|
|
"SELECT COUNT(DISTINCT CrsCod)"
|
|
|
|
|
" FROM projects"
|
|
|
|
|
" WHERE CrsCod>0");
|
2017-09-15 13:19:27 +02:00
|
|
|
|
break;
|
2019-04-03 20:57:04 +02:00
|
|
|
|
case Hie_CTY:
|
2018-11-01 19:23:52 +01:00
|
|
|
|
DB_QuerySELECT (&mysql_res,"can not get number of courses with projects",
|
|
|
|
|
"SELECT COUNT(DISTINCT projects.CrsCod)"
|
|
|
|
|
" FROM institutions,centres,degrees,courses,projects"
|
|
|
|
|
" WHERE institutions.CtyCod=%ld"
|
|
|
|
|
" AND institutions.InsCod=centres.InsCod"
|
|
|
|
|
" AND centres.CtrCod=degrees.CtrCod"
|
|
|
|
|
" AND degrees.DegCod=courses.DegCod"
|
|
|
|
|
" AND courses.Status=0"
|
|
|
|
|
" AND courses.CrsCod=projects.CrsCod",
|
2019-04-03 20:57:04 +02:00
|
|
|
|
Gbl.Hierarchy.Cty.CtyCod);
|
2017-09-15 13:19:27 +02:00
|
|
|
|
break;
|
2019-04-03 20:57:04 +02:00
|
|
|
|
case Hie_INS:
|
2018-11-01 19:23:52 +01:00
|
|
|
|
DB_QuerySELECT (&mysql_res,"can not get number of courses with projects",
|
|
|
|
|
"SELECT COUNT(DISTINCT projects.CrsCod)"
|
|
|
|
|
" FROM centres,degrees,courses,projects"
|
|
|
|
|
" WHERE centres.InsCod=%ld"
|
|
|
|
|
" AND centres.CtrCod=degrees.CtrCod"
|
|
|
|
|
" AND degrees.DegCod=courses.DegCod"
|
|
|
|
|
" AND courses.Status=0"
|
|
|
|
|
" AND courses.CrsCod=projects.CrsCod",
|
2019-04-03 20:57:04 +02:00
|
|
|
|
Gbl.Hierarchy.Ins.InsCod);
|
2017-09-15 13:19:27 +02:00
|
|
|
|
break;
|
2019-04-03 20:57:04 +02:00
|
|
|
|
case Hie_CTR:
|
2018-11-01 19:23:52 +01:00
|
|
|
|
DB_QuerySELECT (&mysql_res,"can not get number of courses with projects",
|
|
|
|
|
"SELECT COUNT(DISTINCT projects.CrsCod)"
|
|
|
|
|
" FROM degrees,courses,projects"
|
|
|
|
|
" WHERE degrees.CtrCod=%ld"
|
|
|
|
|
" AND degrees.DegCod=courses.DegCod"
|
|
|
|
|
" AND courses.Status=0"
|
|
|
|
|
" AND courses.CrsCod=projects.CrsCod",
|
2019-04-03 20:57:04 +02:00
|
|
|
|
Gbl.Hierarchy.Ctr.CtrCod);
|
2017-09-15 13:19:27 +02:00
|
|
|
|
break;
|
2019-04-03 20:57:04 +02:00
|
|
|
|
case Hie_DEG:
|
2018-11-01 19:23:52 +01:00
|
|
|
|
DB_QuerySELECT (&mysql_res,"can not get number of courses with projects",
|
|
|
|
|
"SELECT COUNT(DISTINCT projects.CrsCod)"
|
|
|
|
|
" FROM courses,projects"
|
|
|
|
|
" WHERE courses.DegCod=%ld"
|
|
|
|
|
" AND courses.Status=0"
|
|
|
|
|
" AND courses.CrsCod=projects.CrsCod",
|
2019-04-03 20:57:04 +02:00
|
|
|
|
Gbl.Hierarchy.Deg.DegCod);
|
2017-09-15 13:19:27 +02:00
|
|
|
|
break;
|
2019-04-03 20:57:04 +02:00
|
|
|
|
case Hie_CRS:
|
2018-11-01 19:23:52 +01:00
|
|
|
|
DB_QuerySELECT (&mysql_res,"can not get number of courses with projects",
|
|
|
|
|
"SELECT COUNT(DISTINCT CrsCod)"
|
|
|
|
|
" FROM projects"
|
|
|
|
|
" WHERE CrsCod=%ld",
|
2019-04-04 10:45:15 +02:00
|
|
|
|
Gbl.Hierarchy.Crs.CrsCod);
|
2017-09-15 13:19:27 +02:00
|
|
|
|
break;
|
|
|
|
|
default:
|
2018-10-24 23:03:11 +02:00
|
|
|
|
Lay_WrongScopeExit ();
|
2017-09-15 13:19:27 +02:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Get number of courses *****/
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
|
|
|
|
if (sscanf (row[0],"%u",&NumCourses) != 1)
|
|
|
|
|
Lay_ShowErrorAndExit ("Error when getting number of courses with projects.");
|
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
|
|
|
|
|
return NumCourses;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2017-09-17 16:58:09 +02:00
|
|
|
|
/************************** Get number of projects ***************************/
|
2017-09-15 13:19:27 +02:00
|
|
|
|
/*****************************************************************************/
|
2017-09-17 18:55:02 +02:00
|
|
|
|
// Returns the number of projects in this location
|
2017-09-15 13:19:27 +02:00
|
|
|
|
|
2019-04-03 20:57:04 +02:00
|
|
|
|
unsigned Prj_GetNumProjects (Hie_Level_t Scope)
|
2017-09-15 13:19:27 +02:00
|
|
|
|
{
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
2017-09-17 16:58:09 +02:00
|
|
|
|
unsigned NumProjects;
|
2017-09-15 13:19:27 +02:00
|
|
|
|
|
|
|
|
|
/***** Get number of projects from database *****/
|
|
|
|
|
switch (Scope)
|
|
|
|
|
{
|
2019-04-03 20:57:04 +02:00
|
|
|
|
case Hie_SYS:
|
2018-11-01 19:23:52 +01:00
|
|
|
|
DB_QuerySELECT (&mysql_res,"can not get number of projects",
|
|
|
|
|
"SELECT COUNT(*)"
|
|
|
|
|
" FROM projects"
|
|
|
|
|
" WHERE CrsCod>0");
|
2017-09-15 13:19:27 +02:00
|
|
|
|
break;
|
2019-04-03 20:57:04 +02:00
|
|
|
|
case Hie_CTY:
|
2018-11-01 19:23:52 +01:00
|
|
|
|
DB_QuerySELECT (&mysql_res,"can not get number of projects",
|
|
|
|
|
"SELECT COUNT(*)"
|
|
|
|
|
" FROM institutions,centres,degrees,courses,projects"
|
|
|
|
|
" WHERE institutions.CtyCod=%ld"
|
|
|
|
|
" AND institutions.InsCod=centres.InsCod"
|
|
|
|
|
" AND centres.CtrCod=degrees.CtrCod"
|
|
|
|
|
" AND degrees.DegCod=courses.DegCod"
|
|
|
|
|
" AND courses.CrsCod=projects.CrsCod",
|
2019-04-03 20:57:04 +02:00
|
|
|
|
Gbl.Hierarchy.Cty.CtyCod);
|
2017-09-15 13:19:27 +02:00
|
|
|
|
break;
|
2019-04-03 20:57:04 +02:00
|
|
|
|
case Hie_INS:
|
2018-11-01 19:23:52 +01:00
|
|
|
|
DB_QuerySELECT (&mysql_res,"can not get number of projects",
|
|
|
|
|
"SELECT COUNT(*)"
|
|
|
|
|
" FROM centres,degrees,courses,projects"
|
|
|
|
|
" WHERE centres.InsCod=%ld"
|
|
|
|
|
" AND centres.CtrCod=degrees.CtrCod"
|
|
|
|
|
" AND degrees.DegCod=courses.DegCod"
|
|
|
|
|
" AND courses.CrsCod=projects.CrsCod",
|
2019-04-03 20:57:04 +02:00
|
|
|
|
Gbl.Hierarchy.Ins.InsCod);
|
2017-09-15 13:19:27 +02:00
|
|
|
|
break;
|
2019-04-03 20:57:04 +02:00
|
|
|
|
case Hie_CTR:
|
2018-11-01 19:23:52 +01:00
|
|
|
|
DB_QuerySELECT (&mysql_res,"can not get number of projects",
|
|
|
|
|
"SELECT COUNT(*)"
|
|
|
|
|
" FROM degrees,courses,projects"
|
|
|
|
|
" WHERE degrees.CtrCod=%ld"
|
|
|
|
|
" AND degrees.DegCod=courses.DegCod"
|
|
|
|
|
" AND courses.CrsCod=projects.CrsCod",
|
2019-04-03 20:57:04 +02:00
|
|
|
|
Gbl.Hierarchy.Ctr.CtrCod);
|
2017-09-15 13:19:27 +02:00
|
|
|
|
break;
|
2019-04-03 20:57:04 +02:00
|
|
|
|
case Hie_DEG:
|
2018-11-01 19:23:52 +01:00
|
|
|
|
DB_QuerySELECT (&mysql_res,"can not get number of projects",
|
|
|
|
|
"SELECT COUNT(*)"
|
|
|
|
|
" FROM courses,projects"
|
|
|
|
|
" WHERE courses.DegCod=%ld"
|
|
|
|
|
" AND courses.CrsCod=projects.CrsCod",
|
2019-04-03 20:57:04 +02:00
|
|
|
|
Gbl.Hierarchy.Deg.DegCod);
|
2017-09-15 13:19:27 +02:00
|
|
|
|
break;
|
2019-04-03 20:57:04 +02:00
|
|
|
|
case Hie_CRS:
|
2018-11-01 19:23:52 +01:00
|
|
|
|
DB_QuerySELECT (&mysql_res,"can not get number of projects",
|
|
|
|
|
"SELECT COUNT(*)"
|
|
|
|
|
" FROM projects"
|
|
|
|
|
" WHERE CrsCod=%ld",
|
2019-04-04 10:45:15 +02:00
|
|
|
|
Gbl.Hierarchy.Crs.CrsCod);
|
2017-09-15 13:19:27 +02:00
|
|
|
|
break;
|
|
|
|
|
default:
|
2018-10-24 23:03:11 +02:00
|
|
|
|
Lay_WrongScopeExit ();
|
2017-09-15 13:19:27 +02:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Get number of projects *****/
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
2017-09-17 16:58:09 +02:00
|
|
|
|
if (sscanf (row[0],"%u",&NumProjects) != 1)
|
2017-09-15 13:19:27 +02:00
|
|
|
|
Lay_ShowErrorAndExit ("Error when getting number of projects.");
|
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
|
2017-09-17 16:58:09 +02:00
|
|
|
|
return NumProjects;
|
2017-09-15 13:19:27 +02:00
|
|
|
|
}
|