Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Use CONNECT or CREATE DATABASE to specify a database
- CONNECT "/var/Motiw/db/motiw.fdb" USER 'SYSDBA' PASSWORD 'masterkey';
- SET NAMES WIN1251;
- update patch_info
- set paramvalue = 'Updates to 1.4.18'
- where paramname = 'PATCH_STATUS';
- update patch_info
- set paramvalue = cast(paramvalue as integer) + 1
- where paramname = 'PATCH_STEP';
- SET GENERATOR gen_patch_percent to 0;
- COMMIT WORK;
- /*-----------------------------------------------------------------------------------------------------------------------*/
- /* Ну и по традиции тут удаляем хлам и пережитки прошлой жизни */
- /*-----------------------------------------------------------------------------------------------------------------------*/
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE TMP_DROP_XLAM
- AS
- declare variable is_exist smallint;
- BEGIN
- SELECT result FROM IS_PROCEDURE_EXISTS('GETPERMREE_FOR_EMPLOYER_DOCINIT')
- INTO :is_exist;
- IF (is_exist = 1) THEN
- begin
- EXECUTE STATEMENT
- 'DROP PROCEDURE GETPERMREE_FOR_EMPLOYER_DOCINIT;';
- end
- SELECT result FROM IS_PROCEDURE_EXISTS('GETOPENTASKSFORREPORT4')
- INTO :is_exist;
- IF (is_exist = 1) THEN
- begin
- EXECUTE STATEMENT
- 'DROP PROCEDURE GETOPENTASKSFORREPORT4;';
- end
- SELECT result FROM IS_PROCEDURE_EXISTS('GETALLNOTICES')
- INTO :is_exist;
- IF (is_exist = 1) THEN
- begin
- EXECUTE STATEMENT
- 'DROP PROCEDURE GETALLNOTICES;';
- end
- END ^
- SET TERM ; ^
- commit;
- EXECUTE PROCEDURE TMP_DROP_XLAM;
- commit;
- DROP PROCEDURE TMP_DROP_XLAM;
- commit;
- /* добавляем шаблон задачи по умолчанию */
- EXECUTE PROCEDURE ADD_FIELD_IF_DOES_NOT_EXIST('EMPLOYER', 'TASK_TEMPLATE_DEFAULT', 'INTEGER');
- RESULT
- =======
- 1
- commit;
- /* право на создание задач (для проверки доступности кнопки создания задачи) */
- update menuitems set right_kind = 23
- where item_id = 101;
- commit;
- EXECUTE PROCEDURE ADD_FIELD_IF_DOES_NOT_EXIST('EMPLOYER', 'CAN_ADD_TASK', 'SMALLINT');
- RESULT
- =======
- 1
- commit;
- update employer set can_add_task = 1
- where can_add_task is null;
- commit;
- /*---------------------------------------------------------------------------------------*/
- /* stasy: Группы пользователей*/
- /*---------------------------------------------------------------------------------------*/
- /* Создаем таблицу EMP_GROUPS */
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE TMP_EMP_GROUPS_CREATE
- AS
- declare variable is_exist smallint;
- BEGIN
- /* Гарантируем генератор */
- SELECT result FROM IS_GENERATOR_EXISTS('GEN_EMP_GROUPS_ID')
- INTO :is_exist;
- IF (is_exist = 0) THEN
- BEGIN
- EXECUTE STATEMENT
- 'CREATE GENERATOR GEN_EMP_GROUPS_ID';
- END
- /* Гарантируем таблицу */
- SELECT result FROM IS_TABLE_EXISTS('EMP_GROUPS')
- INTO :is_exist;
- IF (is_exist = 0) THEN
- BEGIN
- EXECUTE STATEMENT
- 'CREATE TABLE EMP_GROUPS (
- ID_GROUP INTEGER NOT NULL,
- TITLE VARCHAR(200) NOT NULL,
- DISCRIPTION VARCHAR(1000),
- IS_DELITED SMALLINT,
- ID_OWNER INTEGER NOT NULL,
- iscommon SMALLINT,
- constraint PK_EMP_GROUPS_ID primary key (ID_GROUP))';
- END
- END ^
- SET TERM ; ^
- commit;
- EXECUTE PROCEDURE TMP_EMP_GROUPS_CREATE;
- commit;
- DROP PROCEDURE TMP_EMP_GROUPS_CREATE;
- commit;
- /* Создаем триггер для генерации ID */
- SET TERM ^;
- CREATE OR ALTER TRIGGER EMP_GROUPS_BI_GEN_ID
- FOR EMP_GROUPS
- ACTIVE BEFORE INSERT
- AS
- BEGIN
- IF (NEW.ID_GROUP IS NULL) THEN
- NEW.ID_GROUP = GEN_ID(GEN_EMP_GROUPS_ID, 1);
- END^
- SET TERM ; ^
- commit;
- /* раздаем гранты на таблицу */
- EXECUTE PROCEDURE GIVE_GRANTS_TO_ALL('TABLE','EMP_GROUPS','ALL');
- commit;
- /* Таблица EMPLOUEROFGROUP */
- /* Создаем таблицу EMPLOUEROFGROUP для связки таблиц EMP_GROUPS и employer (пользователь может находиться в нескольких группах) */
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE TMP_EMPLOYEROFGROUP_CREATE
- AS
- declare variable is_exist smallint;
- BEGIN
- /* Гарантируем таблицу */
- SELECT result FROM IS_TABLE_EXISTS('EMPLOYEROFGROUP')
- INTO :is_exist;
- IF (is_exist = 0) THEN
- BEGIN
- EXECUTE STATEMENT
- 'CREATE TABLE EMPLOYEROFGROUP (
- ID_EMP INTEGER NOT NULL,
- ID_GROUP INTEGER NOT NULL,
- PERMITION SMALLINT,
- IS_DELITED SMALLINT,
- constraint PK_EMPLOYEROFGROUP primary key (ID_EMP, ID_GROUP))';
- END
- END ^
- SET TERM ; ^
- commit;
- EXECUTE PROCEDURE TMP_EMPLOYEROFGROUP_CREATE;
- commit;
- DROP PROCEDURE TMP_EMPLOYEROFGROUP_CREATE;
- commit;
- /* раздаем гранты на таблицу */
- EXECUTE PROCEDURE GIVE_GRANTS_TO_ALL('TABLE','EMPLOYEROFGROUP','ALL');
- commit;
- /*создаем пункт меню группы пользователей*/
- EXECUTE PROCEDURE ADDMENUITEMBYTAG(868, 'L_GLOBAL_PERMISSIONS_GROUP', '/user/empgroup/', 'L_MENU_ADMINISTRATION', 8, 1, 6, NULL);
- commit;
- /*добавляем право на группы пользователей*/
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE GET_RIGHTS_OF_GROUP (
- i_id_employer integer,
- i_id_groupright integer)
- returns (
- o_right_kind integer,
- o_id_object integer,
- o_objectname varchar(1000),
- o_group_has_right smallint,
- o_can_edit smallint)
- as
- declare variable l_id_owner integer;
- declare variable l_id_groupright integer;
- begin
- O_ID_OBJECT = 0;
- O_OBJECTNAME = '';
- for select gl.id
- from grouprights_list gl
- into :O_RIGHT_KIND
- do
- begin
- select o_result from get_right_employer_and_group(:i_id_employer,:o_right_kind,0)
- into :o_can_edit;
- select o_result from get_right_groupright(:i_id_groupright,:o_right_kind,:o_id_object)
- into :o_group_has_right;
- suspend;
- end
- for select dt.id, dt.name, dt.id_owner from doctypes dt
- where dt.isdeleted=0
- into :o_id_object, :o_objectname, :l_id_owner
- do
- begin
- if (l_id_owner=i_id_employer or l_id_owner is null ) then
- o_can_edit = 1;
- else
- o_can_edit = 0;
- o_right_kind = 1;
- select o_result from get_right_groupright(:i_id_groupright,:o_right_kind,:o_id_object)
- into :o_group_has_right;
- suspend;
- o_right_kind = 2;
- select o_result from get_right_groupright(:i_id_groupright,:o_right_kind,:o_id_object)
- into :o_group_has_right;
- suspend;
- o_right_kind = 28; /* 28 - право выбора связанных документов */
- select o_result from get_right_groupright(:i_id_groupright,:o_right_kind,:o_id_object)
- into :o_group_has_right;
- suspend;
- end
- o_right_kind = 3;
- for select rt.id, rt.name, rt.id_owner from routetemplate rt
- where rt.isdeleted=0 and rt.kind=0
- into :o_id_object, :o_objectname, :l_id_owner
- do
- begin
- if (l_id_owner=i_id_employer or l_id_owner is null ) then
- o_can_edit = 1;
- else
- o_can_edit = 0;
- select o_result from get_right_groupright(:i_id_groupright,:o_right_kind,:o_id_object)
- into :o_group_has_right;
- suspend;
- end
- o_right_kind = 9;
- for select fd.id, fd.name, fd.id_owner from fdoctemplate fd
- where fd.isdeleted=0
- into :o_id_object, :o_objectname, :l_id_owner
- do
- begin
- if (l_id_owner=i_id_employer or l_id_owner is null ) then
- o_can_edit = 1;
- else
- o_can_edit = 0;
- select o_result from get_right_groupright(:i_id_groupright,:o_right_kind,:o_id_object)
- into :o_group_has_right;
- suspend;
- end
- o_right_kind = 12;
- for select it.id, it.name, it.id_owner from iwgtemplate it
- where it.isdeleted=0
- into :o_id_object, :o_objectname, :l_id_owner
- do
- begin
- if (l_id_owner=i_id_employer or l_id_owner is null ) then
- o_can_edit = 1;
- else
- o_can_edit = 0;
- select o_result from get_right_groupright(:i_id_groupright,:o_right_kind,:o_id_object)
- into :o_group_has_right;
- suspend;
- end
- o_right_kind = 10;
- if (I_ID_GROUPRIGHT is null) then L_ID_GROUPRIGHT=0;
- else
- L_ID_GROUPRIGHT=:I_ID_GROUPRIGHT;
- for select g.id, g.name, g.id_owner from grouprights g
- where g.isdeleted=0 and g.isvisible=1 and g.id<>:L_ID_GROUPRIGHT
- into :o_id_object, :o_objectname, :l_id_owner
- do
- begin
- if (l_id_owner=i_id_employer ) then
- o_can_edit = 1;
- else
- o_can_edit = 0;
- select o_result from get_right_groupright(:i_id_groupright,:o_right_kind,:o_id_object)
- into :o_group_has_right;
- suspend;
- end
- o_right_kind = 15;
- o_can_edit = 1;
- for select md.id, md.name, md.id_owner
- from meta_dictionary md
- where md.isdeleted=0 and md.id_owner=:i_id_employer and recordtype=1
- into :o_id_object, :o_objectname, :l_id_owner
- do
- begin
- select o_result from get_right_groupright(:i_id_groupright,:o_right_kind,:o_id_object)
- into :o_group_has_right;
- suspend;
- end
- /* 17 права на просмотр записей в справочнике */
- /* 18 права на добавление записей в справочник */
- /* 19 права на изменение записей в справочнике */
- /* 20 права на удаление записей в справочнике */
- o_can_edit = 1;
- for select md.id, md.name, md.id_owner
- from meta_dictionary md
- where md.isdeleted=0 and md.id_owner=:i_id_employer and recordtype=0
- into :o_id_object, :o_objectname, :l_id_owner
- do
- begin
- o_right_kind = 17;
- select o_result from get_right_groupright(:i_id_groupright,:o_right_kind,:o_id_object)
- into :o_group_has_right;
- suspend;
- o_right_kind = 18;
- select o_result from get_right_groupright(:i_id_groupright,:o_right_kind,:o_id_object)
- into :o_group_has_right;
- suspend;
- o_right_kind = 19;
- select o_result from get_right_groupright(:i_id_groupright,:o_right_kind,:o_id_object)
- into :o_group_has_right;
- suspend;
- o_right_kind = 20;
- select o_result from get_right_groupright(:i_id_groupright,:o_right_kind,:o_id_object)
- into :o_group_has_right;
- suspend;
- end
- o_right_kind = 22;
- for select tt.id, tt.name, tt.id_owner from task_templates tt
- into :o_id_object, :o_objectname, :l_id_owner
- do
- begin
- if (l_id_owner=i_id_employer or l_id_owner is null ) then
- o_can_edit = 1;
- else
- o_can_edit = 0;
- select o_result from get_right_groupright(:i_id_groupright,:o_right_kind,:o_id_object)
- into :o_group_has_right;
- suspend;
- end
- -- плагины не привязвнные к типам
- o_right_kind = 77;
- for select plg.id, plg.name, plg.id_owner from plugins plg where plg.no_connect_to_type=1
- into :o_id_object, :o_objectname, :l_id_owner
- do
- begin
- if (l_id_owner=i_id_employer or l_id_owner is null ) then
- o_can_edit = 1;
- else
- o_can_edit = 0;
- select o_result from get_right_groupright(:i_id_groupright,:o_right_kind,:o_id_object)
- into :o_group_has_right;
- suspend;
- end
- /* 23 права на просмотр событий календаря */
- /* 24 права на добавление и редактирование событий в календарь */
- /* 25 полные права*/
- o_can_edit = 1;
- for select c.id, c.name, c.id_owner
- from calendars c
- where c.id_owner=:i_id_employer and is_system=0
- into :o_id_object, :o_objectname, :l_id_owner
- do
- begin
- o_right_kind = 23;
- select o_result from get_right_groupright(:i_id_groupright,:o_right_kind,:o_id_object)
- into :o_group_has_right;
- suspend;
- o_right_kind = 24;
- select o_result from get_right_groupright(:i_id_groupright,:o_right_kind,:o_id_object)
- into :o_group_has_right;
- suspend;
- o_right_kind = 25;
- select o_result from get_right_groupright(:i_id_groupright,:o_right_kind,:o_id_object)
- into :o_group_has_right;
- suspend;
- end
- o_right_kind = 26;
- select o_result from get_right_groupright(:i_id_groupright,:o_right_kind,0)
- into :o_group_has_right;
- suspend;
- /* 27 права на общедоступные группы внешних пользователей */
- for select eeg.id, eeg.name, eeg.id_owner from email_employer_group eeg
- where eeg.isdeleted=0 and eeg.iscommon=1
- into :o_id_object, :o_objectname, :l_id_owner
- do
- begin
- if (l_id_owner=i_id_employer or l_id_owner is null ) then
- o_can_edit = 1;
- else
- o_can_edit = 0;
- o_right_kind = 27;
- select o_result from get_right_groupright(:i_id_groupright,:o_right_kind,:o_id_object)
- into :o_group_has_right;
- suspend;
- end
- /* 29 - права на группы пользователей*/
- for select eeg.id_group, eeg.title, eeg.id_owner from EMP_GROUPS eeg
- where eeg.IS_DELITED=0
- into :o_id_object, :o_objectname, :l_id_owner
- do
- begin
- if (l_id_owner=i_id_employer or l_id_owner is null ) then
- o_can_edit = 1;
- else
- o_can_edit = 0;
- o_right_kind = 29;
- select o_result from get_right_groupright(:i_id_groupright,:o_right_kind,:o_id_object)
- into :o_group_has_right;
- suspend;
- end
- end^
- SET TERM ; ^
- COMMIT;
- /*процедура возвращает системные права пользователей - так, как если бы он создавался
- ** сотрудник - полное право на себя
- ** начальник - полное право на свой отдел и подчиненные
- ** - только свои задачи на начальников и делопроизводителей одного уровня
- ** делопроиз - только свои задачи на свой отдел и подчиненные
- ** - начальников и делопроизводителей одного уровня*/
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE GET_SISTEM_PERM (
- i_id integer)
- returns (
- o_emp integer,
- o_right integer)
- as
- declare variable l_boss integer;
- declare variable l_depid integer;
- declare variable l_empid integer;
- declare variable l_isboss integer;
- declare variable l_mydepid integer;
- declare variable l_myparentdepid integer;
- declare variable l_parentdepid integer;
- BEGIN
- /*проверяем кем является чувак и выбираем его подразделение*/
- select e.isboss, e.id_department from employer e where e.id = :i_id
- into :l_boss, :L_MYDEPID;
- if (:l_boss = 0) then exit;/*если просто сотрудник - то выходим*/
- /*получаем родительское подразделение*/
- select parentid from department
- where id = :L_MYDEPID
- into :L_MYPARENTDEPID;
- /*получаем подразделение "для начальника"*/
- for select O_ID
- from GETTREE_FOR_BOSS (:i_id)
- into :L_DEPID
- do
- begin
- /*находим подразделения одного уровня*/
- select parentid
- from department
- where id=:L_DEPID
- into :L_PARENTDEPID;
- /*и проверяем там каждого сотрудника*/
- for select id, isboss
- from employer
- where isdeleted = 0 and
- id_department = :L_DEPID
- into :o_emp, :L_ISBOSS
- do
- begin /*если оного уровня, но не свое подразделения*/
- if ((:L_MYPARENTDEPID = :L_PARENTDEPID) and
- (:L_ISBOSS > 0) and
- (:L_DEPID <> :L_MYDEPID)) then
- begin/*тогда только свои задачи для начальников*/
- o_right = 2;
- suspend;
- end
- else /*если свое подразделение*/
- begin
- if ((:L_MYPARENTDEPID <> :L_PARENTDEPID) or (:L_DEPID = :L_MYDEPID) ) then
- begin
- if (:l_boss = 1) then
- begin
- o_right = 1;
- suspend;
- end
- else
- begin
- o_right = 2;
- suspend;
- end
- end
- end
- end
- end
- END^
- SET TERM ; ^
- COMMIT;
- /*---------------------------------------------------------------------------------------*/
- /* stasy: Группы пользователей - конец*/
- /*---------------------------------------------------------------------------------------*/
- /*---------------------------------------------------------------------------------------*/
- /* stasy: Задания по событиям - начало*/
- /*---------------------------------------------------------------------------------------*/
- /* 1.1 Создаем таблицу EVENTS_TYPES, в ней будет id события и тег */
- /*---------------------------------------------------------------------------------------*/
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE TMP_JOBS_TYPES_CREATE
- AS
- declare variable is_exist smallint;
- BEGIN
- /* Гарантируем таблицу */
- SELECT result FROM IS_TABLE_EXISTS('JOBS_TYPES')
- INTO :is_exist;
- IF (is_exist = 0) THEN
- BEGIN
- EXECUTE STATEMENT
- 'CREATE TABLE JOBS_TYPES (
- ID_TYPE INTEGER NOT NULL,
- TYPE_NAME VARCHAR(200) NOT NULL,
- constraint PK_JOBS_TYPES primary key (ID_TYPE))';
- END
- END ^
- SET TERM ; ^
- commit;
- EXECUTE PROCEDURE TMP_JOBS_TYPES_CREATE;
- commit;
- DROP PROCEDURE TMP_JOBS_TYPES_CREATE;
- commit;
- /*---------------------------------------------------------------------------------------*/
- /* 1.2 раздаем гранты на таблицу */
- /*---------------------------------------------------------------------------------------*/
- EXECUTE PROCEDURE GIVE_GRANTS_TO_ALL('TABLE','JOBS_TYPES','ALL');
- commit;
- /*---------------------------------------------------------------------------------------*/
- /* 1.3 к этому моменту в ней будет одно значение - "создать подзадачу по шаблону"*/
- /*---------------------------------------------------------------------------------------*/
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE TMP_JOBS_TYPES_INSERT
- AS
- declare variable is_exist smallint;
- BEGIN
- /*если еще пустая*/
- SELECT count(*) from JOBS_TYPES
- INTO :is_exist;
- IF (is_exist = 0) THEN
- BEGIN
- INSERT INTO JOBS_TYPES (ID_TYPE, TYPE_NAME) VALUES (1, 'L_SUB_TASK_BY_TEMPL');
- END
- END ^
- SET TERM ; ^
- commit;
- EXECUTE PROCEDURE TMP_JOBS_TYPES_INSERT;
- commit;
- DROP PROCEDURE TMP_JOBS_TYPES_INSERT;
- commit;
- /*---------------------------------------------------------------------------------------*/
- /* 2.1 Создаем таблицу jobs, в ней будет: локальный id, тип задания и ид задания */
- /*---------------------------------------------------------------------------------------*/
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE TMP_JOBS_CREATE
- AS
- declare variable is_exist smallint;
- BEGIN
- /* Гарантируем генератор */
- SELECT result FROM IS_GENERATOR_EXISTS('GEN_JOB_ID')
- INTO :is_exist;
- IF (is_exist = 0) THEN
- BEGIN
- EXECUTE STATEMENT
- 'CREATE GENERATOR GEN_JOB_ID';
- END
- /* Гарантируем таблицу */
- SELECT result FROM IS_TABLE_EXISTS('JOBS')
- INTO :is_exist;
- IF (is_exist = 0) THEN
- BEGIN
- EXECUTE STATEMENT
- 'CREATE TABLE JOBS (
- ID_JOB_LIST INTEGER,
- ID_JOB INTEGER NOT NULL,
- ID_JOB_TYPE INTEGER NOT NULL,
- constraint PK_JOBS primary key (ID_JOB))';
- END
- END ^
- SET TERM ; ^
- commit;
- EXECUTE PROCEDURE TMP_JOBS_CREATE;
- commit;
- DROP PROCEDURE TMP_JOBS_CREATE;
- commit;
- /*---------------------------------------------------------------------------------------*/
- /* 2.2 Создаем триггер для генерации ID */
- /*---------------------------------------------------------------------------------------*/
- SET TERM ^;
- CREATE OR ALTER TRIGGER JOB_BI_GEN_ID
- FOR JOBS
- ACTIVE BEFORE INSERT
- AS
- BEGIN
- IF (NEW.ID_JOB IS NULL) THEN
- NEW.ID_JOB = GEN_ID(GEN_JOB_ID, 1);
- END^
- SET TERM ; ^
- commit;
- /*---------------------------------------------------------------------------------------*/
- /* 2.3 раздаем гранты на таблицу */
- /*---------------------------------------------------------------------------------------*/
- EXECUTE PROCEDURE GIVE_GRANTS_TO_ALL('TABLE','JOBS','ALL');
- commit;
- /*---------------------------------------------------------------------------------------*/
- /* 3.1 Создаем таблицу job_list, в ней будет: ид из Joba и из связки */
- /*---------------------------------------------------------------------------------------*/
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE TMP_JOB_LIST_CREATE
- AS
- declare variable is_exist smallint;
- BEGIN
- /* Гарантируем генератор */
- SELECT result FROM IS_GENERATOR_EXISTS('GEN_JOB_LIST_ID')
- INTO :is_exist;
- IF (is_exist = 0) THEN
- BEGIN
- EXECUTE STATEMENT
- 'CREATE GENERATOR GEN_JOB_LIST_ID';
- END
- /* Гарантируем таблицу */
- SELECT result FROM IS_TABLE_EXISTS('JOB_LIST')
- INTO :is_exist;
- IF (is_exist = 0) THEN
- BEGIN
- EXECUTE STATEMENT
- 'CREATE TABLE JOB_LIST (
- ID_JOB_LIST INTEGER NOT NULL,
- NAME VARCHAR(200) NOT NULL,
- ID_OWNER INTEGER NOT NULL,
- constraint PK_JOB_LIST primary key (ID_JOB_LIST))';
- END
- END ^
- SET TERM ; ^
- commit;
- EXECUTE PROCEDURE TMP_JOB_LIST_CREATE;
- commit;
- DROP PROCEDURE TMP_JOB_LIST_CREATE;
- commit;
- /*---------------------------------------------------------------------------------------*/
- /* 3.2 Создаем триггер для генерации ID */
- /*---------------------------------------------------------------------------------------*/
- SET TERM ^;
- CREATE OR ALTER TRIGGER JOB_LIST_BI_GEN_ID
- FOR JOB_LIST
- ACTIVE BEFORE INSERT
- AS
- BEGIN
- IF (NEW.ID_JOB_LIST IS NULL) THEN
- NEW.ID_JOB_LIST = GEN_ID(GEN_JOB_LIST_ID, 1);
- END^
- SET TERM ; ^
- commit;
- /*---------------------------------------------------------------------------------------*/
- /* 3.3 раздаем гранты на таблицу */
- /*---------------------------------------------------------------------------------------*/
- EXECUTE PROCEDURE GIVE_GRANTS_TO_ALL('TABLE','JOB_LIST','ALL');
- commit;
- /*---------------------------------------------------------------------------------------*/
- /* 4.1 Создаем таблицу jobs_object, в ней будет: локальный id, тип объекта, его ид и ид задания */
- /*---------------------------------------------------------------------------------------*/
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE TMP_JOBS_OBJECT_CREATE
- AS
- declare variable is_exist smallint;
- BEGIN
- /* Гарантируем генератор */
- SELECT result FROM IS_GENERATOR_EXISTS('GEN_JOBS_OBJECT_ID')
- INTO :is_exist;
- IF (is_exist = 0) THEN
- BEGIN
- EXECUTE STATEMENT
- 'CREATE GENERATOR GEN_JOBS_OBJECT_ID';
- END
- /* Гарантируем таблицу */
- SELECT result FROM IS_TABLE_EXISTS('JOBS_OBJECT')
- INTO :is_exist;
- IF (is_exist = 0) THEN
- BEGIN
- EXECUTE STATEMENT
- 'CREATE TABLE JOBS_OBJECT (
- ID_JOBS_OBJECT INTEGER NOT NULL,
- ID_JOB INTEGER NOT NULL,
- ID_JOBS_OBJECT_TYPE INTEGER NOT NULL,
- ID_OBJECT INTEGER NOT NULL,
- constraint PK_JOBS_OBJECT primary key (ID_JOBS_OBJECT))';
- END
- END ^
- SET TERM ; ^
- commit;
- EXECUTE PROCEDURE TMP_JOBS_OBJECT_CREATE;
- commit;
- DROP PROCEDURE TMP_JOBS_OBJECT_CREATE;
- commit;
- /*---------------------------------------------------------------------------------------*/
- /* 4.2 Создаем триггер для генерации ID */
- /*---------------------------------------------------------------------------------------*/
- SET TERM ^;
- CREATE OR ALTER TRIGGER JOBS_OBJECT_BI_GEN_ID
- FOR JOBS_OBJECT
- ACTIVE BEFORE INSERT
- AS
- BEGIN
- IF (NEW.ID_JOBS_OBJECT IS NULL) THEN
- NEW.ID_JOBS_OBJECT = GEN_ID(GEN_JOBS_OBJECT_ID, 1);
- END^
- SET TERM ; ^
- commit;
- /*---------------------------------------------------------------------------------------*/
- /* 4.3 раздаем гранты на таблицу */
- /*---------------------------------------------------------------------------------------*/
- EXECUTE PROCEDURE GIVE_GRANTS_TO_ALL('TABLE','JOBS_OBJECT','ALL');
- commit;
- /*---------------------------------------------------------------------------------------*/
- /* В очередной раз становимся лучше. теперь так: для запускающих задание объектов одна таблица
- , различаем по типам - 1 - события, 2- задачи, дальше разберемся*/
- /*---------------------------------------------------------------------------------------*/
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE TMP_EVENT_JOBS_CREATE
- AS
- declare variable is_exist smallint;
- BEGIN
- SELECT result FROM IS_TABLE_EXISTS('JOBBERS')
- INTO :is_exist;
- IF (is_exist = 0) THEN
- BEGIN
- EXECUTE STATEMENT
- 'CREATE TABLE JOBBERS (
- ID_JOB_LIST INTEGER NOT NULL,
- ID_JOBBER INTEGER NOT NULL,
- ID_JOBBER_TYPE INTEGER NOT NULL,
- constraint PK_JOBBERS primary key (ID_JOB_LIST, ID_JOBBER, ID_JOBBER_TYPE))';
- END
- END ^
- SET TERM ; ^
- commit;
- EXECUTE PROCEDURE TMP_EVENT_JOBS_CREATE;
- commit;
- DROP PROCEDURE TMP_EVENT_JOBS_CREATE;
- commit;
- /*---------------------------------------------------------------------------------------*/
- /* раздаем гранты на таблицу */
- /*---------------------------------------------------------------------------------------*/
- EXECUTE PROCEDURE GIVE_GRANTS_TO_ALL('TABLE','JOBBERS','ALL');
- commit;
- /*---------------------------------------------------------------------------------------*/
- /* добавляем признак "Выполненное задание" в события */
- /*---------------------------------------------------------------------------------------*/
- EXECUTE PROCEDURE ADD_FIELD_IF_DOES_NOT_EXIST('CALENDAR_PERIODS', 'ISEXECT', 'SMALLINT');
- RESULT
- =======
- 1
- commit;
- /*---------------------------------------------------------------------------------------*/
- /* сбрасываем этот признак для событий, которые уже наступили*/
- /*---------------------------------------------------------------------------------------*/
- UPDATE CALENDAR_PERIODS SET ISEXECT = 1 WHERE START_DATE < 'NOW';
- commit;
- /*---------------------------------------------------------------------------------------*/
- /* stasy: Задания по событиям - конец*/
- /*---------------------------------------------------------------------------------------*/
- /*---------------------------------------------------------------------------------------*/
- /* stasy: Цепочки задач - начало*/
- /*---------------------------------------------------------------------------------------*/
- /*---------------------------------------------------------------------------------------*/
- /* добавляем поле для списков заданий в шаблоны задач */
- /*---------------------------------------------------------------------------------------*/
- EXECUTE PROCEDURE ADD_FIELD_IF_DOES_NOT_EXIST('TASK_TEMPLATES', 'ID_JOB_LIST', 'INTEGER');
- RESULT
- =======
- 1
- commit;
- /*---------------------------------------------------------------------------------------*/
- /* stasy: Цепочки задач - конец*/
- /*---------------------------------------------------------------------------------------*/
- /* Делаем процедуру, которая строит дерево инициаторов или контролеров типа документа в зависимости от параметра i_right_kind */
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE GETPERMREE_FOR_EMPLOYER_DOC (
- i_id integer,
- i_doctypeid integer,
- i_right_kind integer)
- returns (
- o_id integer,
- o_name varchar(200),
- o_level integer)
- as
- declare variable l_k smallint;
- declare variable l_empid integer;
- declare variable l_pred_level integer;
- begin
- l_k = 0;
- l_pred_level = 0;
- for select O_ID,O_NAME,O_LEVEL
- from GETPERMISSIONTREE_FOR_EMPLOYER (:i_id, 0)
- into :O_ID, :o_name, :o_level
- do
- begin
- l_k = 0;
- for select p.id_employer
- from permission p
- join employer e on e.id = p.id_employer
- where e.id_department=:o_id and p.id_boss=:i_id and p.enabled>0 and :l_k=0
- into :L_EMPID
- do
- begin
- if (exists(select grc.id_object
- from grouprights_content grc
- join GROUPRIGHTS_EMPLOYER gre on gre.id_groupright = grc.id_groupright
- where gre.id_employer = :L_EMPID and
- grc.right_kind=:i_right_kind and
- grc.id_object=:i_doctypeid)) then
- l_k=1;
- end
- if (l_k=1) then
- begin
- if (o_level - l_pred_level > 1) then
- o_level = o_level - 1;
- l_pred_level = o_level;
- suspend;
- end
- end
- end^
- SET TERM ; ^
- commit;
- EXECUTE PROCEDURE GIVE_GRANTS_TO_ALL('PROCEDURE','GETPERMREE_FOR_EMPLOYER_DOC','EXECUTE');
- commit;
- /* Признак "Скрывать при поиске" для полей типа задачи */
- EXECUTE PROCEDURE ADD_FIELD_IF_DOES_NOT_EXIST('META_FIELD', 'ISHIDEINSEARCH', 'SMALLINT');
- RESULT
- =======
- 1
- commit;
- /* Шаблон справочника */
- EXECUTE PROCEDURE ADD_FIELD_IF_DOES_NOT_EXIST('META_FIELD', 'DICTIONARY_TEMPLATE', 'VARCHAR(1000)');
- RESULT
- =======
- 1
- commit;
- /* Флаг необходимости смены пароля */
- EXECUTE PROCEDURE ADD_FIELD_IF_DOES_NOT_EXIST('EMPLOYER', 'NEEDPASSWORDCHANGE', 'SMALLINT');
- RESULT
- =======
- 1
- commit;
- /* Elena - Добавила сброс флага NEEDPASSWORDCHANGE при смене пароля*/
- SET TERM ^ ;
- CREATE OR ALTER TRIGGER EMPLOYER_AU0 FOR EMPLOYER
- ACTIVE AFTER UPDATE POSITION 0
- as
- declare variable bossid integer;
- declare variable fbossid integer;
- declare variable projid integer;
- declare variable flag integer;
- declare variable l_empid integer;
- declare variable l_isdeleted integer;
- declare variable l_enabled smallint;
- begin
- if (new.isdeleted = 1 and old.isdeleted = 0) then
- begin
- /* for select id_boss
- from permission
- where id_employer = new.id and
- enabled >0
- into :l_empid
- do
- begin
- select isdeleted from employer where id = :l_empid
- into :l_isdeleted;
- if (l_isdeleted=0) then
- execute procedure set_permission_dep (l_empid, new.id);
- end */
- update permission
- set enabled=0
- where id_boss=new.id;
- /* update permission
- set enabled=0
- where id_employer=new.id; */
- /* Удаляем из всех пользовательских деревьев */
- delete from ud_employer where id_employer=new.id;
- end
- if (new.isdeleted = 0 and old.isdeleted=1) then
- execute procedure convertpermissions (new.id, new.isboss);
- if (new.id_department != old.id_department) then
- begin
- for select distinct t.id_project
- from grouptask gt
- left join task t on (gt.id_task=t.id)
- where gt.id_employer = old.id and gt.is_respperson=1
- into :projid
- do
- begin
- flag = null;
- select count(id_project) from PROJECT_DEP
- where id_Project = :projid and ID_Department = new.id_department
- into :flag; /*проверяем не привязан ли уже этот проект к новому подразделению*/
- if ((flag is null) or (flag = 0)) then /*если нет, то привязываем*/
- insert into PROJECT_DEP (ID_Project, ID_Department)
- values (:projid,new.id_department);
- flag = null;
- /* old begin */
- /* select count (t.id) --проверяем остались ли еще задачи для этого проекта в старом подразделении
- from task t
- join employer e on t.id_employer = e.id
- where t.id_project =:projid and
- t.ID_employer != old.id and
- e.id_department = old.id_department
- into :flag;
- */ /* old end */
- /* new begin */
- select count (t.id) /*проверяем остались ли еще задачи для этого проекта в старом подразделении*/
- from task t
- join grouptask gt on (t.id = gt.id_task and gt.is_worker = 1)
- join employer e on gt.id_employer = e.id
- where t.id_project =:projid and
- gt.ID_employer != old.id and
- e.id_department = old.id_department
- into :flag;
- /* new end */
- if ((flag is null) or (flag = 0)) then /*если нет, то удаляем привязку этого проекта к подразделению*/
- delete from PROJECT_DEP where
- id_project = :projid and
- id_department = old.id_department;
- end
- update permission
- set enabled = 0
- where id_boss = new.id and
- is_manual=0;
- execute procedure convertpermissions (new.id, new.isboss);
- /*Обновляем deppermission для боссов данного пользователя*/
- for select id_boss,enabled
- from permission
- where id_employer = new.id and
- enabled <> 0
- into :l_empid,:l_enabled
- do
- begin
- select isdeleted from employer where id = :l_empid
- into :l_isdeleted;
- if (l_isdeleted = 0) then
- begin
- /* Проверяем имеет ли начальник права на отдел в который перевели чела
- * и если нет, то удаляем права начальника на чела
- */
- if (not (exists(select d.enabled
- from deppermission d
- where d.id_employer=:l_empid and
- d.id_department = new.id_department and
- d.enabled = :l_enabled))) then
- delete from permission p
- where p.id_boss = :l_empid and
- p.id_employer = new.id;
- else
- execute procedure set_permission_dep (l_empid, new.id);
- /*Проверяем старое подразделение и удаляем его из deppermission, если там
- больше нет пользователей, на которых босс имеет права*/
- if (not exists(select p.id_boss
- from permission p
- join employer e on e.id = p.id_employer
- where e.id_department = old.id_department and
- p.id_boss = :l_empid and
- enabled = :l_enabled)) then
- begin
- delete from deppermission
- where id_department = old.id_department and
- id_employer = :l_empid and
- enabled = :l_enabled;
- end
- end
- end
- end
- if (old.isboss <> new.isboss) then /*смена статуса сотрудника, переделываем полномочия*/
- execute procedure convertpermissions (new.id, new.isboss);
- if (old.pass <> new.pass and old.needpasswordchange = new.needpasswordchange) then
- update employer
- set needpasswordchange = 0
- where id = new.id;
- if (old.name<>new.name or
- old.isboss<>new.isboss or
- old.login<>new.login or
- old.pass<>new.pass or
- old.isdeleted<>new.isdeleted or
- old.email<>new.email or
- old.cphone<>new.cphone or
- old.workphone<>new.workphone or
- old.birthdate<>new.birthdate or
- old.postaddress<>new.postaddress or
- old.homephone<>new.homephone or
- old.cphone2<>new.cphone2 or
- old.commnt<>new.commnt or
- old.manpost<>new.manpost or
- old.fastlogin<>new.fastlogin or
- old.awayto<>new.awayto
- ) then
- update employer
- set name = new.name,
- isboss = new.isboss,
- login = new.login,
- pass = new.pass,
- isdeleted = new.isdeleted,
- email = new.email,
- cphone = new.cphone,
- workphone = new.workphone,
- birthdate = new.birthdate,
- postaddress = new.postaddress,
- homephone = new.homephone,
- cphone2 = new.cphone2,
- commnt = new.commnt,
- manpost = new.manpost,
- fastlogin = new.fastlogin,
- awayto=new.awayto
- where parentid = new.id and
- isdeleted = 0;
- end^
- SET TERM ; ^
- commit;
- /*-------------------------------------------------------------------------------------------------------------------------------*/
- /* пункт меню "Интеграция с LDAP" */
- /*-------------------------------------------------------------------------------------------------------------------------------*/
- EXECUTE PROCEDURE ADDMENUITEMBYTAG(869, 'L_MENU_LDAP', 'http://ldapsync_host:ldapsync_port', 'L_MENU_ADMINISTRATION', 21, 1, 6, NULL);
- commit;
- /* Elena - Добавила выходной параметр id_tasktype*/
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE GETTASKINFO4SF (
- idemployer integer,
- idtask integer)
- returns (
- taskid integer,
- tasknumber varchar(200),
- priority integer,
- taskname varchar(2000),
- startdate date,
- enddate date,
- author varchar(10000),
- controller varchar(10000),
- responsible varchar(10000),
- worker varchar(10000),
- projectname varchar(10000),
- tasktype varchar(10000),
- taskstate char(4),
- marker integer,
- id_tasktype integer)
- as
- declare variable is_author smallint;
- declare variable is_controller smallint;
- declare variable is_responsible smallint;
- declare variable is_worker smallint;
- declare variable emp_name varchar(2000);
- declare variable act_cnt integer;
- declare variable istasknew smallint;
- declare variable isactnew smallint;
- declare variable isreport smallint;
- declare variable isreject smallint;
- declare variable i integer;
- declare variable sql varchar(1000);
- BEGIN
- SQL = '';
- if (idtask<>-1) then
- begin
- SQL = ' and t.ID = ' || :idtask;
- end
- for EXECUTE STATEMENT 'select
- t.ID,
- lower(t.NUMERATOR),
- t.PRIORITY,
- lower(t.NAME),
- t.STARTDATE,
- t.ENDDATE,
- lower(p.NAME),
- lower(md.NAME),
- md.id,
- ta.MARKER_COLOR,
- t.action_count,
- (1 - gt.IS_VIEWED_TASK),
- (1-(case ta.IS_VIEW_NEW_ACTIONS when (ta.IS_VIEW_NEW_ACTIONS) then ta.IS_VIEW_NEW_ACTIONS else 0 end)),
- t.ISREPORTED,
- t.ISREJECTED
- from
- TASK t
- join GROUPTASK gt on
- t.ID = gt.ID_TASK
- join PROJECT p on
- p.id = t.ID_PROJECT
- join META_DICTIONARY md on
- md.ID = t.ID_META_DICTIONARY
- left join TASK_ATTRIBUTES ta on
- ta.ID_TASK = gt.ID_TASK and ta.id_employer=gt.id_original
- where
- gt.id_original = ' || :idemployer || ' and gt.task_state=0' || :SQL
- into
- :TASKID,
- :TASKNUMBER,
- :PRIORITY,
- :TASKNAME,
- :STARTDATE,
- :ENDDATE,
- :PROJECTNAME,
- :TASKTYPE,
- :ID_TASKTYPE,
- :MARKER,
- :ACT_CNT,
- :istasknew,
- :isactnew,
- :isreport,
- :isreject
- do
- begin
- Author = '';
- Controller = '';
- Responsible = '';
- Worker = '';
- for
- select
- gt.IS_AUTHOR,
- gt.IS_CONTROLER,
- gt.IS_RESPPERSON,
- gt.IS_WORKER,
- e.NAME
- from
- GROUPTASK gt
- join EMPLOYER e on
- e.ID = gt.ID_EMPLOYER
- where
- gt.ID_TASK = :TASKID
- into
- :is_author,
- :is_controller,
- :is_responsible,
- :is_worker,
- :emp_name
- do
- begin
- if (is_author = 1) then
- begin
- if (Author <> '') then Author = Author || ',';
- Author = Author || emp_name;
- end
- if (is_controller = 1) then
- begin
- if (Controller <> '') then Controller = Controller || ',';
- Controller = Controller || emp_name;
- end
- if (is_responsible = 1) then
- begin
- if (Responsible <> '') then Responsible = Responsible || ',';
- Responsible = Responsible || emp_name;
- end
- if (is_worker = 1) then
- begin
- if (Worker <> '') then Worker = Worker || ',';
- Worker = Worker || emp_name;
- end
- end
- if ( ( (ACT_CNT=0)or(ACT_CNT is null) ) ) then isactnew = 0;
- if (isreject is null) then isreject = 0;
- taskstate = istasknew || isactnew || isreport || isreject;
- SUSPEND;
- end
- END^
- SET TERM ; ^
- commit;
- /*-------------------------------------------------------------------------------------------------------------------------------*/
- /*stasy: shablon otobrajenia imeni documenta begining*/
- /*-------------------------------------------------------------------------------------------------------------------------------*/
- EXECUTE PROCEDURE ADD_FIELD_IF_DOES_NOT_EXIST('DOCTYPES', 'DISPLAY_NAME', 'VARCHAR(1000)');
- RESULT
- =======
- 1
- commit;
- /*-------------------------------------------------------------------------------------------------------------------------------*/
- /*shablon otobrajenia imeni documenta end*/
- /*-------------------------------------------------------------------------------------------------------------------------------*/
- /*tip resolucii - begin*/
- /*isnachalno nepravilno bilo, chishu*/
- /*-------------------------------------------------------------------------------------------------------------------------------*/
- delete from doccards where FIELDID = 'RESOLUTION_TYPE' and FIELDTYPE = 104;
- commit;
- /*-------------------------------------------------------------------------------------------------------------------------------*/
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE DROD_FIELD_IF_EXIST
- (
- table_name varchar(50),
- field_name varchar(50)
- )
- RETURNS
- (
- result SMALLINT
- )
- AS
- DECLARE VARIABLE is_exist SMALLINT;
- BEGIN
- result = 0;
- SELECT result FROM IS_FIELD_EXISTS(:table_name, :field_name)
- INTO :is_exist;
- IF (is_exist > 0) THEN
- BEGIN
- table_name = UPPER(table_name);
- field_name = UPPER(field_name);
- EXECUTE STATEMENT
- 'ALTER TABLE ' || table_name || ' DROP ' || field_name ;
- result = 1;
- END
- SUSPEND;
- END^
- SET TERM ; ^
- COMMIT;
- /*-------------------------------------------------------------------------------------------------------------------------------*/
- EXECUTE PROCEDURE DROD_FIELD_IF_EXIST('DOCCARDS', 'RESOLUTION_TYPE');
- RESULT
- =======
- 0
- commit;
- /*-------------------------------------------------------------------------------------------------------------------------------*/
- EXECUTE PROCEDURE ADD_FIELD_IF_DOES_NOT_EXIST('DOCTYPES', 'RESOLUTION_TYPE', 'INTEGER');
- RESULT
- =======
- 1
- commit;
- /*tip resolucii - end*/
- /*-------------------------------------------------------------------------------------------------------------------------------*/
- EXECUTE PROCEDURE ADD_INDEX_IF_DOES_NOT_EXIST('IDX_META_FIELD1','META_FIELD','NAME, ISDELETED');
- RESULT
- =======
- 1
- commit;
- EXECUTE PROCEDURE ADD_INDEX_IF_DOES_NOT_EXIST('DOCTYPES_IDX1', 'DOCTYPES', 'ISDELETED');
- RESULT
- =======
- 0
- commit;
- /*-----------------------------------------------------------------------------------------------------------------------------------------------*/
- /*01.03.2011, Alisa.Kot, task 270434
- /*-----------------------------------------------------------------------------------------------------------------------------------------------*/
- /*-----------------------------------------------------------------------------------------------------------------------------------------------*/
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE GETTASKEXECDOCBUTOUTDATE_1 (
- I_FROM_DATE Timestamp,
- I_TO_DATE Timestamp,
- I_ID_DEPARTMENT Integer )
- RETURNS (
- O_TASKID Integer,
- O_PROJID Integer,
- O_DOC_EXEC_ID Integer )
- AS
- begin
- for select t.id, t.id_project
- from task t
- where t.state = 1 and
- t.isdeleted = 0 and
- t.tsreport > t.enddate and
- t.id_department = :i_id_department and
- t.enddate between :i_from_date and :i_to_date and
- t.tsreport between :i_from_date and :i_to_date
- into :o_taskid, :O_PROJID
- do
- suspend;
- end^
- SET TERM ; ^
- commit;
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE GETTASKEXECDOCBUTOUTDATE (
- I_ID_EMPLOYER Integer,
- I_ID_DEPARTMENT Integer,
- I_ONLY_THIS_DEP Smallint,
- I_FROM_DATE Timestamp,
- I_TO_DATE Timestamp )
- RETURNS (
- O_TASK_NAME Varchar(2000),
- O_AUTHOR Varchar(2000),
- O_ADATE Timestamp,
- O_TASKID Integer,
- O_AUTHORID Integer,
- O_TASKENDDATE Timestamp,
- O_STATE Smallint,
- O_ACT_EMPID Integer,
- O_TASKSTARTDATE Timestamp,
- O_EMPLOYERID Integer,
- O_EMPLOYERNAME Varchar(2000),
- O_ISBOSS Smallint,
- O_PROJID Integer,
- O_PROJECT_NAME Varchar(200),
- O_DIFFTIME Timestamp,
- O_NUMERATOR Varchar(1000),
- O_TSREPORT Timestamp )
- AS
- DECLARE VARIABLE L_DEPID INTEGER;
- DECLARE VARIABLE L_LAST_ACTIONID INTEGER;
- DECLARE VARIABLE L_LAST_ACTIONTIME TIMESTAMP;
- DECLARE VARIABLE L_REPORTDATE TIMESTAMP;
- DECLARE VARIABLE L_LEFTDATE TIMESTAMP;
- DECLARE VARIABLE L_RIGHTDATE TIMESTAMP;
- DECLARE VARIABLE L_RESULT SMALLINT;
- DECLARE VARIABLE L_ROOT_DEP INTEGER;
- DECLARE VARIABLE L_HASCHILDS INTEGER;
- DECLARE VARIABLE L_TASK_DOC_EXEC_ID INTEGER;
- DECLARE VARIABLE L_DOCID INTEGER;
- DECLARE VARIABLE L_DOC_TYPE_ID INTEGER;
- DECLARE VARIABLE L_DOC_STATE SMALLINT;
- DECLARE VARIABLE L_IS_WHITH_REPORT SMALLINT;
- DECLARE VARIABLE L_ISREPORTED SMALLINT;
- begin
- if (:i_id_department is not null) then
- begin
- l_root_dep = :i_id_department;
- end
- else
- select id_department from employer where id=:i_id_employer
- into :l_root_dep;
- if (:i_only_this_dep = 0) then
- begin
- select haschilds from department where id = :l_root_dep
- into :l_haschilds;
- if (:l_haschilds = 0) then
- i_only_this_dep = 1;
- end
- for select g.o_taskid, g.o_projid
- from gettaskexecdocbutoutdate_1(:i_from_date, :i_to_date, :l_root_dep) g
- into :o_taskid, :o_projid
- do
- begin
- execute procedure checkrightsfortask(:i_id_employer, :o_taskid)
- returning_values :l_result;
- if(:l_result = 1) then
- begin
- select t.name, t.startdate, t.enddate, t.la_id, t.iswithreport, t.isreported, t.tsreport, t.numerator
- from task t
- where t.id = :o_taskid
- into :o_task_name, :o_taskstartdate, :o_taskenddate, :l_last_actionid, :l_is_whith_report, :l_isreported, :l_reportdate, :O_NUMERATOR;
- select first 1 a.adate
- from actions a
- where a.id=:l_last_actionid
- into :l_last_actiontime;
- select first 1 gt.id_employer
- from grouptask gt
- where gt.id_task=:o_taskid and gt.is_author=1
- into :o_authorid;
- select first 1 gt.id_employer
- from grouptask gt
- where gt.id_task=:o_taskid and gt.is_respperson=1
- into :o_employerid;
- select name from employer where id = :o_authorid
- into :o_author;
- select p.name from project p
- where p.id = :o_projid
- into :O_PROJECT_NAME;
- select name from employer where id = :o_employerid
- into :o_employername;
- /* if (l_is_whith_report=1) then
- begin
- if (l_isreported=1) then
- begin
- l_leftdate=:l_reportdate;
- l_rightdate=:o_taskenddate;
- O_DIFFTIME = cast((cast(:l_leftdate as timestamp)-cast(:l_rightdate as timestamp))*100 as integer)/100;
- end
- else
- begin
- O_DIFFTIME = cast((cast(:l_last_actiontime as timestamp)-cast(:o_taskenddate as timestamp))*100 as integer)/100;
- end
- end
- else
- begin
- O_DIFFTIME = cast((cast(:l_last_actiontime as timestamp)-cast(:o_taskenddate as timestamp))*100 as integer)/100;
- end
- */
- --O_DIFFTIME = :l_reportdate - :o_taskenddate;
- O_TSREPORT = :l_reportdate;
- suspend;
- end
- end
- if (:i_only_this_dep = 0) then
- begin
- for select id_department
- from deppermission
- where id_employer=:i_id_employer and enabled > 0
- into :l_depid
- do
- begin
- select o_result from is_sub_dep(:l_depid, :l_root_dep) into :l_result;
- if (:l_result = 1) then
- begin
- for select g.o_taskid, g.o_projid
- from gettaskexecdocbutoutdate_1(:i_from_date, :i_to_date, :l_depid) g
- into :o_taskid, :o_projid
- do
- begin
- execute procedure checkrightsfortask(:i_id_employer, :o_taskid)
- returning_values :l_result;
- if(:l_result = 1) then
- begin
- select t.name, t.startdate, t.enddate, t.la_id, t.iswithreport, t.isreported, t.tsreport, t.numerator
- from task t
- where t.id = :o_taskid
- into :o_task_name, :o_taskstartdate, :o_taskenddate, :l_last_actionid, :l_is_whith_report, :l_isreported, :l_reportdate, :O_NUMERATOR;
- select first 1 a.adate
- from actions a
- where a.id=:l_last_actionid
- into :l_last_actiontime;
- select first 1 gt.id_employer
- from grouptask gt
- where gt.id_task=:o_taskid and gt.is_author=1
- into :o_authorid;
- select first 1 gt.id_employer
- from grouptask gt
- where gt.id_task=:o_taskid and gt.is_respperson=1
- into :o_employerid;
- select name from employer where id = :o_authorid
- into :o_author;
- select p.name from project p
- where p.id = :o_projid
- into :O_PROJECT_NAME;
- select name from employer where id = :o_employerid
- into :o_employername;
- --O_DIFFTIME = :l_reportdate - :o_taskenddate;
- O_TSREPORT = :l_reportdate;
- suspend;
- end
- end
- end
- end
- end
- end^
- SET TERM ; ^
- commit;
- /*-----------------------------------------------------------------------------------------------------------------------------------------------*/
- /*-----------------------------------------------------------------------------------------------------------------------------------------------*/
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE GETOUTDATED_1 (
- I_ID_EMPLOYER Integer,
- I_IS_BOSS Smallint,
- I_ID_DEPARTMENT Smallint )
- RETURNS (
- O_TASKID Integer,
- O_EMPLOYERID Integer,
- O_DEPID Integer )
- AS
- DECLARE VARIABLE L_IS_BOSS SMALLINT;
- DECLARE VARIABLE L_ISSECRET SMALLINT;
- begin
- for
- select t.id,t.issecret
- from task t
- where
- t.isdeleted =0 and
- t.id_department = :i_id_department and
- (select o_result from checkrightsfortask (:I_ID_EMPLOYER, t.id)) = 1 and
- t.enddate < 'NOW' and
- t.state = 0
- into :O_TASKID,:l_issecret
- do
- begin
- if (:l_issecret=0 or (:l_issecret=1 and
- exists (select gt.id_task
- from grouptask gt
- where gt.id_task=:o_taskid and
- gt.id_original=:i_id_employer) ) ) then
- begin
- for select gt.id_employer
- from grouptask gt
- where gt.id_task = :O_TASKID and
- (gt.is_respperson=1 or gt.is_worker=1)
- into :O_EMPLOYERID
- do
- begin
- select id_department,isboss from employer
- where id = :O_EMPLOYERID
- into :O_DEPID,:l_is_boss;
- if ((:I_IS_BOSS=1 and :l_is_boss=1) or :I_IS_BOSS=0) then
- suspend;
- end
- end
- end
- end^
- SET TERM ; ^
- commit;
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE GETOUTDATED (
- I_ID_EMPLOYER Integer,
- I_DEPID Integer,
- I_ONLY_BOSS Smallint,
- I_ONLY_THIS_DEP Smallint )
- RETURNS (
- NAME Varchar(2000),
- TASK_NAME Varchar(2000),
- AUTHOR Varchar(2000),
- CURR_ACTION Blob sub_type 1,
- ADATE Timestamp,
- TASKID Integer,
- AUTHORID Integer,
- TASKENDDATE Timestamp,
- STATE Smallint,
- ACT_EMPID Integer,
- TASKSTARTDATE Timestamp,
- EMPLOYERID Integer,
- EMPLOYERNAME Varchar(2000),
- ISBOSS Smallint,
- O_PROJECT_ID Integer,
- O_PROJECT_NAME Varchar(200),
- O_DIFFTIME Integer,
- O_NUMERATOR Varchar(1000) )
- AS
- declare variable L_TASKID integer;
- declare variable L_STARTDATE timestamp;
- declare variable L_DEPID integer;
- declare variable L_AUTHORNAME varchar(2000);
- declare variable L_RESULT smallint;
- begin
- for select
- distinct g1.o_taskid
- from getpermissiontree (:I_ID_EMPLOYER, :I_DEPID) gpt,
- getoutdated_1(:I_ID_EMPLOYER,:i_only_boss,:i_depid) g1
- where gpt.o_id = g1.o_depid
- into :TASKID
- do
- begin
- select NAME,
- TASK_NAME,
- AUTHOR,
- CURR_ACTION,
- ADATE,
- AUTHORID,
- TASKENDDATE,
- STATE,
- ACT_EMPID,
- TASKSTARTDATE,
- EMPLOYERID,
- EMPLOYERNAME,
- ISBOSS,
- O_PROJECT_ID,
- O_PROJECT_NAME,
- O_DIFFTIME,
- O_NUMERATOR
- from getoutdated_3(:TASKID)
- into :NAME,
- :TASK_NAME,
- :AUTHOR,
- :CURR_ACTION,
- :ADATE,
- :AUTHORID,
- :TASKENDDATE,
- :STATE,
- :ACT_EMPID,
- :TASKSTARTDATE,
- :EMPLOYERID,
- :EMPLOYERNAME,
- :ISBOSS,
- :O_PROJECT_ID,
- :O_PROJECT_NAME,
- :O_DIFFTIME,
- :O_NUMERATOR;
- suspend;
- end
- if (:i_only_this_dep = 0) then
- begin
- for select id_department
- from deppermission
- where id_employer=:i_id_employer and enabled > 0
- into :l_depid
- do
- begin
- select o_result from is_sub_dep(:l_depid, :i_depid) into :l_result;
- if (:l_result = 1) then
- begin
- for select
- distinct g1.o_taskid
- from getpermissiontree (:I_ID_EMPLOYER, :L_DEPID) gpt,
- getoutdated_1(:I_ID_EMPLOYER,:i_only_boss,:l_depid) g1
- where gpt.o_id = g1.o_depid
- into :TASKID
- do
- begin
- select NAME,
- TASK_NAME,
- AUTHOR,
- CURR_ACTION,
- ADATE,
- AUTHORID,
- TASKENDDATE,
- STATE,
- ACT_EMPID,
- TASKSTARTDATE,
- EMPLOYERID,
- EMPLOYERNAME,
- ISBOSS,
- O_PROJECT_ID,
- O_PROJECT_NAME,
- O_DIFFTIME,
- O_NUMERATOR
- from getoutdated_3(:TASKID)
- into :NAME,
- :TASK_NAME,
- :AUTHOR,
- :CURR_ACTION,
- :ADATE,
- :AUTHORID,
- :TASKENDDATE,
- :STATE,
- :ACT_EMPID,
- :TASKSTARTDATE,
- :EMPLOYERID,
- :EMPLOYERNAME,
- :ISBOSS,
- :O_PROJECT_ID,
- :O_PROJECT_NAME,
- :O_DIFFTIME,
- :O_NUMERATOR;
- suspend;
- end
- end
- end
- end
- end^
- SET TERM ; ^
- commit;
- /*-----------------------------------------------------------------------------------------------------------------------------------------------*/
- /*-----------------------------------------------------------------------------------------------------------------------------------------------*/
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE REPORT1 (
- I_ID_EMPLOYER Integer,
- I_DEPID Integer,
- STARTDATE Timestamp,
- ENDDATE Timestamp,
- I_ONLY_THIS_DEP Smallint )
- RETURNS (
- NAME Varchar(2000),
- TASK_NAME Varchar(2000),
- CURR_ACTION Blob sub_type 1,
- ADATE Timestamp,
- TASKID Integer,
- ISSTARTED Smallint,
- PROJNAME Varchar(200),
- DEPPATH Varchar(2000),
- TASKENDDATE Timestamp,
- STATE Smallint,
- ISREJECTED Smallint,
- PROJ_ID Integer,
- ACT_EMPID Integer,
- ACT_FIRST Integer,
- TASKSTARTDATE Timestamp,
- ISBOSS Smallint,
- ISTRASHPROJECT Smallint )
- AS
- declare variable L_STARTDATE timestamp;
- declare variable L_DEPID integer;
- declare variable L_AUTHORNAME varchar(2000);
- declare variable L_RESULT Smallint;
- begin
- if (I_DEPID <> 0) then
- for select rf.name,
- rf.TASK_NAME,
- rf.taskstartdate,
- rf.TASKID,
- rf.isstarted,
- rf.ProjName,
- rf.deppath,
- rf.taskenddate,
- rf.STATE,
- rf.isrejected,
- rf.PROJ_ID,
- rf.isboss,
- rf.istrashproject,
- rf.curr_action,
- rf.adate,
- rf.act_empid,
- rf.act_first
- from getpermissiontree (:I_ID_EMPLOYER, :I_DEPID) gpt,
- report1_fast(:i_id_employer,:startdate,:enddate) rf
- where rf.depid = gpt.o_id
- into :name,
- :TASK_NAME,
- :taskstartdate,
- :TASKID,
- :isstarted,
- :ProjName,
- :deppath,
- :taskenddate,
- :STATE,
- :isrejected,
- :PROJ_ID,
- :isboss,
- :istrashproject,
- :curr_action,
- :adate,
- :act_empid,
- :act_first
- do
- suspend;
- else
- for select rf.name,
- rf.TASK_NAME,
- rf.taskstartdate,
- rf.TASKID,
- rf.isstarted,
- rf.ProjName,
- rf.deppath,
- rf.taskenddate,
- rf.STATE,
- rf.isrejected,
- rf.PROJ_ID,
- rf.isboss,
- rf.istrashproject,
- rf.curr_action,
- rf.adate,
- rf.act_empid,
- rf.act_first
- from getpermissiontree_for_employer (:I_ID_EMPLOYER,0) gpt,
- report1_fast(:i_id_employer,:startdate,:enddate) rf
- where rf.depid = gpt.o_id
- into :name,
- :TASK_NAME,
- :taskstartdate,
- :TASKID,
- :isstarted,
- :ProjName,
- :deppath,
- :taskenddate,
- :STATE,
- :isrejected,
- :PROJ_ID,
- :isboss,
- :istrashproject,
- :curr_action,
- :adate,
- :act_empid,
- :act_first
- do
- suspend;
- if (:i_only_this_dep = 0) then
- begin
- for select id_department
- from deppermission
- where id_employer=:i_id_employer and enabled > 0
- into :l_depid
- do
- begin
- select o_result from is_sub_dep(:l_depid, :i_depid) into :l_result;
- if (:l_result = 1) then
- begin
- for select t.name,
- t.id,
- t.startdate,
- t.enddate,
- t.state,
- t.id_project,
- t.isrejected,
- t.isstarted,
- a.name,
- a.isfirst,
- a.adate,
- a.id_employer,
- e.name,
- e.isboss
- from actions a
- join task t on t.la_id = a.id
- left join employer e on a.id_employer=e.id
- where a.adate between :startdate and :enddate and
- t.isdeleted = 0 and
- e.id_department= :l_depid and
- (select o_result from checkrightsfortask(:i_id_employer, t.id)) = 1
- into :task_name,
- :taskid,
- :taskstartdate,
- :taskenddate,
- :state,
- :proj_id,
- :isrejected,
- :isstarted,
- :curr_action,
- :act_first,
- :adate,
- :act_empid,
- :name,
- :isboss
- do
- suspend;
- end
- suspend;
- end
- end
- end^
- SET TERM ; ^
- commit;
- /*-----------------------------------------------------------------------------------------------------------------------------------------------*/
- /*-----------------------------------------------------------------------------------------------------------------------------------------------*/
- /*------------------------------------------------------------------------------------------------------------------------------*/
- /* Добавление столбца EXECTIME в таблицу DOCUMENTTEMPLATE*/
- /*------------------------------------------------------------------------------------------------------------------------------*/
- EXECUTE PROCEDURE ADD_FIELD_IF_DOES_NOT_EXIST('DOCUMENTTEMPLATE', 'EXECTIME', 'TIMESTAMP');
- RESULT
- =======
- 0
- commit;
- /*------------------------------------------------------------------------------------------------------------------------------*/
- /* Процедура для втавки актуального уровня в поле IS_CURRENT в таблице ROUTETREES */
- /*------------------------------------------------------------------------------------------------------------------------------*/
- EXECUTE PROCEDURE ADD_FIELD_IF_DOES_NOT_EXIST_D('ROUTETREES', 'IS_CURRENT', 'INTEGER', '0');
- RESULT
- =======
- 1
- commit;
- SET TERM ^ ;
- CREATE PROCEDURE INSERTROUTEACTUALLEVELS
- AS
- declare variable idtask integer;
- declare variable iscurrent integer;
- declare variable iddocument integer;
- declare variable r_stage integer;
- declare variable current_doc integer;
- declare variable is_exist smallint;
- BEGIN
- select count(is_current) from ROUTETREES where is_current > 0
- into :is_exist;
- if(is_exist = 0) then
- BEGIN
- current_doc=0;
- for select max(stage) as stage, id_document from ROUTETREES
- group by id_document
- into :r_stage, :iddocument
- DO
- BEGIN
- if(current_doc<>:iddocument) then
- BEGIN
- update ROUTETREES set is_current=0 where id_document=:iddocument;
- select first 1 id_task from routetrees rt, task t
- where rt.ID_TASK=t.ID and t.STATE=0 and rt.ID_DOCUMENT=:iddocument and rt.STAGE=:r_stage
- into :idtask;
- update ROUTETREES set is_current=1 where id_task=:idtask and id_document=:iddocument and stage=:r_stage;
- current_doc=iddocument;
- END
- END
- END
- END ^
- SET TERM ; ^
- EXECUTE PROCEDURE INSERTROUTEACTUALLEVELS;
- commit;
- DROP PROCEDURE INSERTROUTEACTUALLEVELS;
- commit;
- /*------------------------------------------------------------------------------------*/
- /*stasy - avto dobavlenie postanovchika v zadachi v raznie roly
- nachalo*/
- /*------------------------------------------------------------------------------------*/
- EXECUTE PROCEDURE ADD_FIELD_IF_DOES_NOT_EXIST('TASK_TEMPLATES', 'REALAUTHOR_AS_AUTHOR', 'SMALLINT');
- RESULT
- =======
- 1
- commit;
- EXECUTE PROCEDURE ADD_FIELD_IF_DOES_NOT_EXIST('TASK_TEMPLATES', 'REALAUTHOR_AS_RESPPERSON', 'SMALLINT');
- RESULT
- =======
- 1
- commit;
- EXECUTE PROCEDURE ADD_FIELD_IF_DOES_NOT_EXIST('TASK_TEMPLATES', 'REALAUTHOR_AS_CONTROLER', 'SMALLINT');
- RESULT
- =======
- 1
- commit;
- EXECUTE PROCEDURE ADD_FIELD_IF_DOES_NOT_EXIST('TASK_TEMPLATES', 'REALAUTHOR_AS_WORKER', 'SMALLINT');
- RESULT
- =======
- 1
- commit;
- /*------------------------------------------------------------------------------------*/
- /*konec*/
- /*------------------------------------------------------------------------------------*/
- /*-----------------------------------------------------------------------------------------------------------------------------------------------*/
- /*stasy & Elena: drop hlam*/
- /*-----------------------------------------------------------------------------------------------------------------------------------------------*/
- delete from menuitems m where m.dmess_tagname = 'L_OPTIONS_DOCPREFS3' and m.item_id = 889;
- commit;
- delete from employer_settings where settings_key='DOCUMENT_PREFS_DEFAULT_SETTINGS';
- commit;
- delete from notification_prefs np where np.task_attribute = 2;
- commit;
- /* Delete search menu items */
- delete from menuitems m where m.item_id in (951, 952, 953, 954, 955, 956) or m.dmess_tagname = 'L_GLOBAL_SEARCH';
- commit;
- /*-----------------------------------------------------------------------------------------------------------------------------------------------*/
- /*stasy - opoveshenie o vipolnenii kt*/
- /*------------------------------------------------------------------------------------*/
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE TMP_KT_READY_NOTIFI
- AS
- declare variable is_exist smallint;
- BEGIN
- select count (np.task_attribute) from notification_prefs np where id_employer=0 and action_type = 20
- INTO :is_exist;
- IF (is_exist > 0) THEN exit;
- INSERT INTO NOTIFICATION_PREFS
- (ACTION_TYPE, TASK_ATTRIBUTE, ID_EMPLOYER, SMS, MAIL, SMS_DISABLE, MAIL_DISABLE, EDITION)
- VALUES (20, 1, 0, 1, 1, 0, 0, NULL);
- INSERT INTO NOTIFICATION_PREFS
- (ACTION_TYPE, TASK_ATTRIBUTE, ID_EMPLOYER, SMS, MAIL, SMS_DISABLE, MAIL_DISABLE, EDITION)
- VALUES (20, 3, 0, 1, 1, 0, 0, NULL);
- INSERT INTO NOTIFICATION_PREFS
- (ACTION_TYPE, TASK_ATTRIBUTE, ID_EMPLOYER, SMS, MAIL, SMS_DISABLE, MAIL_DISABLE, EDITION)
- VALUES (20, 4, 0, 1, 1, 0, 0, NULL);
- INSERT INTO NOTIFICATION_PREFS
- (ACTION_TYPE, TASK_ATTRIBUTE, ID_EMPLOYER, SMS, MAIL, SMS_DISABLE, MAIL_DISABLE, EDITION)
- VALUES (20, 5, 0, 1, 1, 0, 0, NULL);
- INSERT INTO NOTIFICATION_PREFS
- (ACTION_TYPE, TASK_ATTRIBUTE, ID_EMPLOYER, SMS, MAIL, SMS_DISABLE, MAIL_DISABLE, EDITION)
- VALUES (20, 6, 0, 1, 1, 0, 0, NULL);
- INSERT INTO NOTIFICATION_PREFS
- (ACTION_TYPE, TASK_ATTRIBUTE, ID_EMPLOYER, SMS, MAIL, SMS_DISABLE, MAIL_DISABLE, EDITION)
- VALUES (20, 7, 0, 1, 1, 0, 0, NULL);
- INSERT INTO NOTIFICATION_PREFS
- (ACTION_TYPE, TASK_ATTRIBUTE, ID_EMPLOYER, SMS, MAIL, SMS_DISABLE, MAIL_DISABLE, EDITION)
- VALUES (20, 8, 0, 1, 1, 0, 0, NULL);
- END ^
- SET TERM ; ^
- commit;
- EXECUTE PROCEDURE TMP_KT_READY_NOTIFI;
- commit;
- DROP PROCEDURE TMP_KT_READY_NOTIFI;
- commit;
- /*------------------------------------------------------------------------------------*/
- /*stasy - opoveshenie o vipolnenii kt - conec*/
- /*------------------------------------------------------------------------------------*/
- /*stasy - procedura proveraet, javlaetsy li odna zapis' spravochnika potomkom drugoy*/
- /*------------------------------------------------------------------------------------*/
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE IS_PARENT_CHILDE_RECORD (
- i_childe integer,
- i_parent integer)
- returns (
- o_result integer)
- as
- declare variable temp_childe integer;
- declare variable temp_perent integer;
- begin
- for select id_parent from meta_record where id = :i_childe
- into :temp_perent
- do
- begin
- if (:temp_perent = :i_parent) then
- begin
- o_result = 1;
- suspend;
- exit;
- end
- if (:temp_perent is null) then
- begin
- o_result = 0;
- suspend;
- exit;
- end
- select o_result from IS_PARENT_CHILDE_RECORD (:temp_perent, :i_parent)
- into :o_result;
- suspend;
- end
- end ^
- SET TERM ; ^
- commit;
- /*------------------------------------------------------------------------------------*/
- /*conec*/
- /*------------------------------------------------------------------------------------*/
- /*------------------------------------------------------------------------------------*/
- /*stasy - indecsi dl'auskorenija otchetow*/
- /*------------------------------------------------------------------------------------*/
- EXECUTE PROCEDURE ADD_INDEX_IF_DOES_NOT_EXIST('DDOCUMENT_REPORTS_INDEX_1', 'DOCUMENTS', 'ISDELETED,STATE,REGDATE');
- RESULT
- =======
- 0
- commit;
- EXECUTE PROCEDURE ADD_INDEX_IF_DOES_NOT_EXIST('DOC_TASK_REPORTS_INDEX_1', 'GROUPTASK', 'TASK_ID_DOCUMENT, ID_EMPLOYER');
- RESULT
- =======
- 0
- commit;
- /*------------------------------------------------------------------------------------*/
- /*------------------------------------------------------------------------------------*/
- /*stasy - merzkiy trigger*/
- /*------------------------------------------------------------------------------------*/
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE TMP_DROP_MERSKIY_TRIGGER
- AS
- declare variable is_exist smallint;
- BEGIN
- SELECT result FROM IS_TRIGGER_EXISTS('NOTICEVIEW_AU0')
- INTO :is_exist;
- IF (is_exist = 1) THEN
- begin
- EXECUTE STATEMENT
- 'DROP TRIGGER NOTICEVIEW_AU0;';
- end
- END ^
- SET TERM ; ^
- commit;
- EXECUTE PROCEDURE TMP_DROP_MERSKIY_TRIGGER;
- commit;
- DROP PROCEDURE TMP_DROP_MERSKIY_TRIGGER;
- commit;
- /*------------------------------------------------------------------------------------*/
- EXECUTE PROCEDURE ADD_FIELD_IF_DOES_NOT_EXIST('NOTICEVIEW', 'ISDELETED', 'SMALLINT');
- RESULT
- =======
- 1
- commit;
- /*---------------------------------------------------------------------------------*/
- /*stasy - rasshirenniy obshii reestr*/
- /*---------------------------------------------------------------------------------*/
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE GETTREE_ID_ONLI (
- i_id integer)
- returns (
- o_id integer)
- as
- begin
- O_ID = I_ID;
- suspend;
- for SELECT ID
- FROM department d
- WHERE PARENTID = :I_ID and isdeleted = 0
- INTO :O_ID
- do
- begin
- for SELECT o_id
- FROM GETTREE_ID_ONLI (:O_ID)
- INTO :O_ID
- do
- suspend;
- end
- end^
- SET TERM ; ^
- commit;
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE GET_FURIGHT_EMP_BY_DEP (
- i_empid integer,
- i_depid integer,
- i_only_this_dep smallint)
- returns (
- o_id_department integer,
- o_empid integer)
- as
- declare variable l_flag smallint;
- declare variable l_depid integer;
- begin
- if (I_ONLY_THIS_DEP = 1) then
- begin
- for select id, e.id_department from employer e
- join permission p on (p.id_boss = :i_empid and p.enabled = 1 and e.id = p.id_employer)
- where e.id_department = :I_DEPID and
- e.isdeleted = 0
- into :O_EMPID,
- :o_id_department
- do
- suspend;
- end
- else
- for select gt.o_id from GETTREE_ID_ONLI (:I_DEPID) gt
- join deppermission dp on ( dp.id_department = gt.o_id
- and id_employer = :i_empid
- and enabled = 1 )
- INTO :L_DEPID
- do
- begin
- begin
- for select id, e.id_department from employer e
- join permission p on (p.id_boss = :i_empid and p.enabled = 1 and e.id = p.id_employer)
- where e.id_department = :L_DEPID and
- e.isdeleted = 0
- into :O_EMPID,
- :o_id_department
- do
- suspend;
- end
- end
- END^
- SET TERM ; ^
- commit;
- /*--------------------------------------------------------------------------------------------------------*/
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE GETDOCUMENTS_REGISTRY (
- i_id_employer integer,
- i_id_department integer,
- i_id_doctype integer,
- i_only_thisdep smallint,
- i_from_date timestamp,
- i_to_date timestamp)
- returns (
- o_id_document integer,
- o_createdate timestamp,
- o_regdate timestamp,
- o_state smallint,
- o_taskid integer,
- o_doc_version integer,
- o_document_files varchar(30000))
- as
- declare variable l_rootdepid integer;
- declare variable l_department integer;
- begin
- if (i_id_department is null) then
- select id_department from employer where id = :i_id_employer
- into :l_rootdepid;
- else
- l_rootdepid = :i_id_department;
- begin
- for select distinct d.id , (select first 1 g.id_task
- from grouptask g
- where g.task_id_document = d.id
- and g.task_id_document <>0
- and g.task_state = 0), d.id_department
- from documents d
- where d.id_department in (select o_id from GETTREE_ID_ONLI (:l_rootdepid))
- and d.regdate >= :i_from_date
- and d.regdate <= :i_to_date
- and d.id_doctype = :I_ID_DOCTYPE
- and
- (
- (d.id_author in (select p.id_employer
- from permission p
- where p.id_boss = :i_id_employer
- and p.enabled = 1))
- or
- (d.id in (select distinct g.task_id_document
- from grouptask g
- where g.id_employer in
- (select p.id_employer
- from permission p
- where p.id_boss = :i_id_employer
- and p.enabled = 1)
- and g.task_id_document <>0)
- )
- )
- into :o_id_document,
- :o_taskid,
- :l_department
- do
- begin
- if (i_only_thisdep = 0 or l_department = i_id_department)
- then
- begin
- select
- d.createdate,
- d.regdate,
- d.state,
- d.doc_version
- from documents d
- where d.id=:o_id_document
- into
- :o_createdate,
- :o_regdate,
- :o_state,
- :o_doc_version;
- select o_document_files from get_doc_files_list(:o_id_document,0)
- into :o_document_files;
- suspend;
- end
- end
- end
- END^
- SET TERM ; ^
- commit;
- /*-------------------------------------------------------------------------------------------------------------*/
- /*ryazanova -----------dobavlenie v adresnyju knigy polzovatelej(292714)----------------------------------------*/
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE UPDATE_ADRESS_BOOK
- AS
- DECLARE VARIABLE lRecID INTEGER;
- DECLARE VARIABLE lDepID INTEGER;
- DECLARE VARIABLE lEmp_ID_Rec INTEGER;
- BEGIN
- FOR
- select d.id_record, em.id_department, em.id_rec_dict
- from employer em, dictionaryrecordtype d
- where em.id_rec_dict = d.id_record and em.isdeleted = 0 and d.id_system = 0
- and em.parentid is null and em.id_department is not null
- INTO :lRecID, :lDepID, :lEmp_ID_Rec
- DO
- BEGIN
- IF (:lRecID IS NOT NULL) THEN
- BEGIN
- UPDATE dictionaryrecordtype d
- SET d.is_system = 1, d.id_system = :lDepID
- WHERE d.id_record = :lRecID;
- END
- END
- END
- ^
- SET TERM ; ^
- EXECUTE PROCEDURE UPDATE_ADRESS_BOOK;
- DROP PROCEDURE UPDATE_ADRESS_BOOK;
- COMMIT;
- /*-------------------------------------------------------------------------------------------------------------*/
- /*------------------------------------------------------------------------------------*/
- /*pmv: polya adresnoi knigi po ymolchaniy */
- /*------------------------------------------------------------------------------------*/
- SET TERM ^ ;
- CREATE OR ALTER procedure SET_ADDRESS_BOOK
- as
- begin
- IF (NOT EXISTS(SELECT
- SETTINGS_VALUE
- FROM EMPLOYER_SETTINGS where (ID_EMPLOYER is null) and (SETTINGS_KEY='table-contacts-grid-state'))) THEN
- BEGIN
- update EMPLOYER_SETTINGS set SETTINGS_VALUE='[{"dataIndex":"path","header":"","sortable":true,"type":1,"width":200,"id":0},{"dataIndex":"f38","header":"","sortable":true,"type":1,"width":200,"hidden":false,"id":1},{"dataIndex":"f39","header":"","sortable":true,"type":1,"width":200,"hidden":false,"id":2},{"dataIndex":"f40","header":"","sortable":true,"type":1,"width":200,"hidden":false,"id":3},{"dataIndex":"f41","header":"","sortable":true,"type":5,"width":90,"hidden":false,"id":4},{"dataIndex":"f42","header":"","sortable":true,"type":1,"width":200,"hidden":false,"id":5},{"dataIndex":"f43","header":"","sortable":true,"type":12,"width":20,"hidden":false,"id":6},{"dataIndex":"f44","header":"","sortable":true,"type":1,"width":200,"hidden":false,"id":7},{"dataIndex":"f45","header":"","sortable":true,"type":1,"width":200,"hidden":false,"id":8},{"dataIndex":"f46","header":"","sortable":true,"type":1,"width":200,"hidden":false,"id":9},{"dataIndex":"f47","header":"","sortable":true,"type":1,"width":200,"hidden":false,"id":10},{"dataIndex":"f48","header":"","sortable":true,"type":1,"width":200,"hidden":false,"id":11},{"dataIndex":"f49","header":"","sortable":true,"type":10,"width":200,"hidden":false,"id":12},{"dataIndex":"f50","header":"","sortable":true,"type":10,"width":200,"hidden":false,"id":13},{"dataIndex":"f51","header":"","sortable":true,"type":10,"width":200,"hidden":false,"id":14},{"dataIndex":"f52","header":"","sortable":true,"type":11,"width":200,"hidden":false,"id":15},{"dataIndex":"f53","header":"","sortable":true,"type":1,"width":200,"hidden":true,"id":16},{"dataIndex":"f54","header":"","sortable":true,"type":2,"width":200,"hidden":true,"id":17},{"dataIndex":"f122","header":"","sortable":true,"type":3,"width":100,"hidden":true,"id":18},{"dataIndex":"f123","header":"","sortable":true,"type":1,"width":200,"hidden":true,"id":19},{"dataIndex":"f124","header":"","sortable":true,"type":1,"width":200,"hidden":true,"id":20},{"dataIndex":"f125","header":"","sortable":true,"type":1,"width":200,"hidden":true,"id":21},{"dataIndex":"f126","header":"","sortable":true,"type":1,"width":200,"hidden":true,"id":22},{"dataIndex":"f127","header":"","sortable":true,"type":13,"width":200,"hidden":true,"id":23},{"dataIndex":"f128","header":"","sortable":true,"type":5,"width":90,"hidden":true,"id":24},{"dataIndex":"f149","header":"","sortable":true,"type":12,"width":20,"hidden":true,"id":33},{"dataIndex":"f140","header":"","sortable":true,"type":8,"width":200,"hidden":true,"id":30},{"dataIndex":"f131","header":"","sortable":true,"type":11,"width":200,"hidden":true,"id":25},{"dataIndex":"f143","header":"","sortable":true,"type":10,"width":200,"hidden":true,"id":31},{"dataIndex":"f144","header":"","sortable":true,"type":2,"width":200,"hidden":true,"id":32},{"dataIndex":"f134","header":"","sortable":true,"type":4,"width":50,"hidden":true,"id":26},{"dataIndex":"f135","header":"","sortable":true,"type":3,"width":100,"hidden":true,"id":27},{"dataIndex":"f136","header":"","sortable":true,"type":6,"width":20,"hidden":true,"id":28},{"dataIndex":"f137","header":"","sortable":true,"type":9,"width":200,"hidden":true,"id":29},{"dataIndex":"f150","header":"","sortable":true,"type":1,"width":200,"hidden":true,"id":34},{"dataIndex":"f152","header":"","sortable":true,"type":12,"width":20,"hidden":true,"id":35}]' where (SETTINGS_KEY='table-contacts-grid-state') and (SETTINGS_VALUE='[{"dataIndex":"path","header":"","sortable":true,"type":1,"width":200,"id":0},{"dataIndex":"f38","header":"","sortable":true,"type":1,"width":200,"hidden":true,"id":1},{"dataIndex":"f39","header":"","sortable":true,"type":1,"width":200,"hidden":true,"id":2},{"dataIndex":"f40","header":"","sortable":true,"type":1,"width":200,"hidden":true,"id":3},{"dataIndex":"f41","header":"","sortable":true,"type":5,"width":90,"hidden":true,"id":4},{"dataIndex":"f42","header":"","sortable":true,"type":1,"width":200,"hidden":true,"id":5},{"dataIndex":"f43","header":"","sortable":true,"type":12,"width":20,"hidden":true,"id":6},{"dataIndex":"f44","header":"","sortable":true,"type":1,"width":200,"hidden":true,"id":7},{"dataIndex":"f45","header":"","sortable":true,"type":1,"width":200,"hidden":true,"id":8},{"dataIndex":"f46","header":"","sortable":true,"type":1,"width":200,"hidden":true,"id":9},{"dataIndex":"f47","header":"","sortable":true,"type":1,"width":200,"hidden":true,"id":10},{"dataIndex":"f48","header":"","sortable":true,"type":1,"width":200,"hidden":true,"id":11},{"dataIndex":"f49","header":"","sortable":true,"type":10,"width":200,"hidden":true,"id":12},{"dataIndex":"f50","header":"","sortable":true,"type":10,"width":200,"hidden":true,"id":13},{"dataIndex":"f51","header":"","sortable":true,"type":10,"width":200,"hidden":true,"id":14},{"dataIndex":"f52","header":"","sortable":true,"type":11,"width":200,"hidden":true,"id":15},{"dataIndex":"f53","header":"","sortable":true,"type":1,"width":200,"hidden":true,"id":16},{"dataIndex":"f54","header":"","sortable":true,"type":2,"width":200,"hidden":true,"id":17},{"dataIndex":"f122","header":"","sortable":true,"type":3,"width":100,"hidden":true,"id":18},{"dataIndex":"f123","header":"","sortable":true,"type":1,"width":200,"hidden":true,"id":19},{"dataIndex":"f124","header":"","sortable":true,"type":1,"width":200,"hidden":true,"id":20},{"dataIndex":"f125","header":"","sortable":true,"type":1,"width":200,"hidden":true,"id":21},{"dataIndex":"f126","header":"","sortable":true,"type":1,"width":200,"hidden":true,"id":22},{"dataIndex":"f127","header":"","sortable":true,"type":13,"width":200,"hidden":true,"id":23},{"dataIndex":"f128","header":"","sortable":true,"type":5,"width":90,"hidden":true,"id":24},{"dataIndex":"f149","header":"","sortable":true,"type":12,"width":20,"hidden":true,"id":33},{"dataIndex":"f140","header":"","sortable":true,"type":8,"width":200,"hidden":true,"id":30},{"dataIndex":"f131","header":"","sortable":true,"type":11,"width":200,"hidden":true,"id":25},{"dataIndex":"f143","header":"","sortable":true,"type":10,"width":200,"hidden":true,"id":31},{"dataIndex":"f144","header":"","sortable":true,"type":2,"width":200,"hidden":true,"id":32},{"dataIndex":"f134","header":"","sortable":true,"type":4,"width":50,"hidden":true,"id":26},{"dataIndex":"f135","header":"","sortable":true,"type":3,"width":100,"hidden":true,"id":27},{"dataIndex":"f136","header":"","sortable":true,"type":6,"width":20,"hidden":true,"id":28},{"dataIndex":"f137","header":"","sortable":true,"type":9,"width":200,"hidden":true,"id":29},{"dataIndex":"f150","header":"","sortable":true,"type":1,"width":200,"hidden":true,"id":34},{"dataIndex":"f152","header":"","sortable":true,"type":12,"width":20,"hidden":true,"id":35}]');
- INSERT INTO EMPLOYER_SETTINGS(SETTINGS_KEY, SETTINGS_VALUE) values ('table-contacts-grid-state', '[{"dataIndex":"path","header":"","sortable":true,"type":1,"width":200,"id":0},{"dataIndex":"f38","header":"","sortable":true,"type":1,"width":200,"hidden":false,"id":1},{"dataIndex":"f39","header":"","sortable":true,"type":1,"width":200,"hidden":false,"id":2},{"dataIndex":"f40","header":"","sortable":true,"type":1,"width":200,"hidden":false,"id":3},{"dataIndex":"f41","header":"","sortable":true,"type":5,"width":90,"hidden":false,"id":4},{"dataIndex":"f42","header":"","sortable":true,"type":1,"width":200,"hidden":false,"id":5},{"dataIndex":"f43","header":"","sortable":true,"type":12,"width":20,"hidden":false,"id":6},{"dataIndex":"f44","header":"","sortable":true,"type":1,"width":200,"hidden":false,"id":7},{"dataIndex":"f45","header":"","sortable":true,"type":1,"width":200,"hidden":false,"id":8},{"dataIndex":"f46","header":"","sortable":true,"type":1,"width":200,"hidden":false,"id":9},{"dataIndex":"f47","header":"","sortable":true,"type":1,"width":200,"hidden":false,"id":10},{"dataIndex":"f48","header":"","sortable":true,"type":1,"width":200,"hidden":false,"id":11},{"dataIndex":"f49","header":"","sortable":true,"type":10,"width":200,"hidden":false,"id":12},{"dataIndex":"f50","header":"","sortable":true,"type":10,"width":200,"hidden":false,"id":13},{"dataIndex":"f51","header":"","sortable":true,"type":10,"width":200,"hidden":false,"id":14},{"dataIndex":"f52","header":"","sortable":true,"type":11,"width":200,"hidden":false,"id":15},{"dataIndex":"f53","header":"","sortable":true,"type":1,"width":200,"hidden":true,"id":16},{"dataIndex":"f54","header":"","sortable":true,"type":2,"width":200,"hidden":true,"id":17},{"dataIndex":"f122","header":"","sortable":true,"type":3,"width":100,"hidden":true,"id":18},{"dataIndex":"f123","header":"","sortable":true,"type":1,"width":200,"hidden":true,"id":19},{"dataIndex":"f124","header":"","sortable":true,"type":1,"width":200,"hidden":true,"id":20},{"dataIndex":"f125","header":"","sortable":true,"type":1,"width":200,"hidden":true,"id":21},{"dataIndex":"f126","header":"","sortable":true,"type":1,"width":200,"hidden":true,"id":22},{"dataIndex":"f127","header":"","sortable":true,"type":13,"width":200,"hidden":true,"id":23},{"dataIndex":"f128","header":"","sortable":true,"type":5,"width":90,"hidden":true,"id":24},{"dataIndex":"f149","header":"","sortable":true,"type":12,"width":20,"hidden":true,"id":33},{"dataIndex":"f140","header":"","sortable":true,"type":8,"width":200,"hidden":true,"id":30},{"dataIndex":"f131","header":"","sortable":true,"type":11,"width":200,"hidden":true,"id":25},{"dataIndex":"f143","header":"","sortable":true,"type":10,"width":200,"hidden":true,"id":31},{"dataIndex":"f144","header":"","sortable":true,"type":2,"width":200,"hidden":true,"id":32},{"dataIndex":"f134","header":"","sortable":true,"type":4,"width":50,"hidden":true,"id":26},{"dataIndex":"f135","header":"","sortable":true,"type":3,"width":100,"hidden":true,"id":27},{"dataIndex":"f136","header":"","sortable":true,"type":6,"width":20,"hidden":true,"id":28},{"dataIndex":"f137","header":"","sortable":true,"type":9,"width":200,"hidden":true,"id":29},{"dataIndex":"f150","header":"","sortable":true,"type":1,"width":200,"hidden":true,"id":34},{"dataIndex":"f152","header":"","sortable":true,"type":12,"width":20,"hidden":true,"id":35}]');
- END
- suspend;
- end
- ^
- SET TERM ; ^
- commit;
- execute procedure set_address_book;
- commit;
- drop procedure set_address_book;
- commit;
- /*-------------------------------------------------------------------------------------------------------------*/
- /*valer00n: Сортировка папок библиотеки по типам*/
- SET TERM ^ ;
- ALTER PROCEDURE GET_DL_USERTREE (
- I_ID_PARENT Integer,
- I_LEVEL Integer,
- EMPID Integer )
- RETURNS (
- O_ID Integer,
- O_NAME Varchar(200),
- O_LEVEL Integer,
- O_RIGHTS Integer,
- O_OBJ_TYPE Integer )
- AS
- DECLARE VARIABLE L_SUB_RIGHT SMALLINT;
- DECLARE VARIABLE L_NEXT_LEVEL SMALLINT;
- begin
- L_NEXT_LEVEL=:i_level;
- for select df.ID, df.NAME,dp.rights,dp.issubrights, df.OBJ_TYPE
- from DLFOLDER df
- join dlpermissions dp on (dp.id_dlfolder=df.id and dp.id_employer=:EMPID)
- where df.isdeleted =0 and df.parentid=:I_ID_PARENT order by df.OBJ_TYPE,df.name
- into :o_id,:o_name,:O_RIGHTS,:l_sub_right,:o_obj_type
- do
- begin
- L_NEXT_LEVEL=:i_level;
- if (:O_RIGHTS>0) then
- begin
- L_NEXT_LEVEL=:i_level+1;
- o_level=:i_level;
- suspend;
- end
- if (:O_RIGHTS>0 or :l_sub_right>0) then
- begin
- for select gdlt.o_id,gdlt.o_name,gdlt.o_level,gdlt.o_rights, gdlt.o_obj_type
- from get_dl_usertree(:o_id,:l_next_level,:empid) gdlt
- into :o_id,:o_name,:o_level,:o_rights,:o_obj_type
- do
- suspend;
- end
- end
- end^
- SET TERM ; ^
- commit;
- SET TERM ^ ;
- ALTER PROCEDURE GETDLPERMTREE_FOR_EMPLOYER (
- I_ID Integer )
- RETURNS (
- O_ID Integer,
- O_NAME Varchar(2000),
- O_LEVEL Integer,
- RIGHTS Integer,
- O_OBJ_TYPE Integer )
- AS
- DECLARE VARIABLE L_ROOTDEP INTEGER;
- DECLARE VARIABLE L_ROOTDEP_NAME INTEGER;
- DECLARE VARIABLE START_LEVEL INTEGER;
- DECLARE VARIABLE IS_ADMIN INTEGER;
- DECLARE VARIABLE ADMIN_DEP INTEGER;
- begin
- select id
- from dlfolder
- where parentid = 0
- and isdeleted<>1
- into :L_ROOTDEP;
- select O_RESULT from GET_RIGHT_EMPLOYER_AND_GROUP(:I_ID,7,0) into :is_admin;
- /* if (is_admin=1) then
- begin
- SELECT id, name, 0, 0
- from dlfolder
- where parentid = 0
- and isdeleted<>1
- into :O_ID, :O_NAME, :O_LEVEL, :RIGHTS;
- suspend;
- for
- SELECT o_id, o_name, o_level,O_RIGHTS FROM GETDLOLDTREE(:L_ROOTDEP, 1, :I_ID)
- INTO :O_ID, :O_NAME, :O_LEVEL,:RIGHTS
- do
- suspend;
- select d.id from employer e join dlfolder d on d.id_obj=e.id_department
- where e.id=:i_id and d.isdeleted=0 and d.obj_type=1 into :admin_dep;
- SELECT id, name, 1, 0
- from dlfolder d
- where d.id=:admin_dep
- into :O_ID, :O_NAME, :O_LEVEL, :RIGHTS;
- suspend;
- RIGHTS=3;
- for
- SELECT o_id, o_name, o_level FROM GETDLSYSTREE(:admin_dep, 1)
- INTO :O_ID, :O_NAME, :O_LEVEL
- do
- suspend;
- end
- else begin */
- for
- SELECT o_id, o_name, o_level,O_RIGHTS,O_OBJ_TYPE FROM GET_DL_USERTREE(0, 0, :I_ID)
- INTO :O_ID, :O_NAME, :O_LEVEL,:RIGHTS,:O_OBJ_TYPE
- do
- suspend;
- --end
- end^
- SET TERM ; ^
- commit;
- /*------------------------------------------------------------*/
- /*-------------------------------------------------------------------------------------------------------------*/
- /*kos: edited the trigger for tasks and - close and deleted project*/
- /*--------------------------------------------------------------------------------------------------------------*/
- SET TERM ^ ;
- CREATE OR ALTER trigger task_au0 for task
- active before update position 0
- as
- declare variable task_id int;
- declare variable task_count int;
- declare variable l_idroutetree integer;
- declare variable l_idemployer integer;
- declare variable l_idnotice integer;
- declare variable l_id_docexec integer;
- declare variable l_task_valuation_id integer;
- begin
- --закрывается без доклада
- if (new.iswithreport = 0 and old.state = 0 and new.state = 1) then new.tsreport = 'now';
- --задача с докладом
- if (new.iswithreport = 1) then
- begin
- --доклад отправлен, но задача не закрыта
- if (old.isreported=0 and new.isreported=1 and new.state = 0) then
- new.respp_report = 'now';
- --задача закрыта
- if (old.state = 0 and new.state = 1) then
- new.tsreport = 'now';
- --возвращена на доработку
- if (old.isreported=1 and new.isreported=0 and new.state = 0) then
- new.respp_report = null;
- end
- if (new.isdeleted=1 and old.isdeleted =0) then
- begin
- update attachment set isdeleted = 1
- where id_task=new.id;
- end
- if (new.isdeleted=1 and old.isdeleted =0) then
- begin
- update attachment set isdeleted = 1
- where id_task=new.id;
- end
- /* меняем task_state в grouptask */
- update grouptask set task_state=new.state
- where id_task=new.id and (task_state != new.state or task_state is null);
- if (new.state =1 and old.state = 0) then /*закрытие задачи - снимаем с контроля*/
- begin
- delete from hiddentasks where id_task=new.id;
- select count (id) from task
- where id_project =old.id_project
- and state= 0
- into :task_count;
- /*напоминания*/
- for select n.id from notice n where n.id_task = new.id
- into :l_idnotice do
- begin
- execute procedure delete_notice(:l_idnotice);
- end
- end
- if (new.state = 0 and old.state = 1) then /*восстановление задачи + проект*/
- begin
- update project set state=0
- where id=new.id_project and state!=0;
- new.id_valuation=null;/*сбрасываем точку восстановленной*/
- update grouptask gt set gt.is_viewed_task=0 where gt.id_task=new.id;
- update actions a set a.examinated=0 where a.examinated=1 and a.id_task=new.id;
- end
- end
- ^
- SET TERM ; ^
- COMMIT;
- SET TERM ^ ;
- CREATE OR ALTER trigger department_bu0 for department
- active before update position 0
- as
- declare variable newname varchar (200);
- declare variable l_count integer;
- begin
- if (new.isdeleted = 1 and old.isdeleted = 0) then
- begin
- update employer
- set isdeleted =1
- where id_department = new.id;
- end
- if (new.name <> old.name) then
- begin
- newname = new.name || ': {L_GLOBAL_TASK_OUTOFPROJ}';
- update project set name = :newname
- where ID_Department = new.id and istrash = 1;
- end
- end
- ^
- SET TERM ; ^
- COMMIT;
- /*-------------------------------------------------------------------------------------------------------------*/
- EXECUTE PROCEDURE ADD_INDEX_IF_DOES_NOT_EXIST('NOTICE_IDX5', 'NOTICE', 'ISDELETED');
- RESULT
- =======
- 1
- commit;
- EXECUTE PROCEDURE ADD_INDEX_IF_DOES_NOT_EXIST('GROUPTASK_IDX2', 'GROUPTASK', 'ID_ORIGINAL, IS_HIDDEN_TASK, SHOW_TASK_DATE');
- RESULT
- =======
- 1
- commit;
- /*-------------------------------------------------------------------------------------------------------------*/
- /* Alisa Kotova, svetograd.motiw.ru task 6675 - get arcive documents by type and registration date*/
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE GETDOCUMENTS_ARCHIVE_MY (
- I_EMPLOYER_ID Integer,
- I_REGDATE_FROM Timestamp,
- I_REGDATE_TO Timestamp )
- RETURNS (
- O_DOC_TYPE Integer,
- O_DOCID Integer,
- O_IS_RIGHT_ARHIV Integer )
- AS
- declare variable is_emplouer integer; /*есть права на автора*/
- declare variable is_autor integer; /*есть права на участника задач по документу*/
- begin
- /*----------------------------------------------------------------------------------------*/
- for select d.id, (select p.ID_Boss
- from permission p
- where p.ID_Boss = :i_employer_id
- and p.ID_Employer = d.id_author
- and p.enabled = 1
- ), d.id_doctype
- from documents d
- where d.regdate >= :i_regdate_from and d.regdate <= :i_regdate_to
- and d.state = 4 and d.isdeleted = 0
- into :o_docid,
- :is_autor,
- :o_doc_type
- do
- /*----------------------------------------------------------------------------------------*/
- /*если есть права на атора документа, то все, в архив попадает*/
- if (is_autor <> 0) then
- begin
- O_IS_RIGHT_ARHIV = 1;
- suspend;
- end
- /*----------------------------------------------------------------------------------------*/
- /*если нет, проверяем права на участников задач по документу (с ботами блин)*/
- else
- begin
- select count (g.task_id_document)
- from grouptask g
- where g.task_id_document = :o_docid
- and g.id_employer in (select p.id_employer from permission p
- where p.id_boss = :i_employer_id
- and p.enabled = 1)
- into :is_emplouer;
- /*----------------------------------------------------------------------------------------*/
- /*если подходящие задачи есть, то все ок, попадает в отчет*/
- if (is_emplouer <> 0) then
- begin
- O_IS_RIGHT_ARHIV = 1;
- end
- /*----------------------------------------------------------------------------------------*/
- /*если нет, то без вариантов - этого документа в отчете нет*/
- else
- begin
- O_IS_RIGHT_ARHIV = 0;
- end
- suspend;
- end
- end^
- SET TERM ; ^
- commit;
- GRANT EXECUTE
- ON PROCEDURE GETDOCUMENTS_ARCHIVE_MY TO SYSDBA;
- commit;
- /* PM Kratkaya informaciya*/
- EXECUTE PROCEDURE ADDMENUITEMBYTAG(903, 'L_MENU_BRIEF_INFO', '/user/hellopageuser/', 'L_ADDITIONAL', 3, 1, 0, NULL);
- commit;
- /* Unique attribute for doccard field */
- EXECUTE PROCEDURE ADD_FIELD_IF_DOES_NOT_EXIST_D('DOCCARDS', 'ISUNIQUE', 'SMALLINT', '0');
- RESULT
- =======
- 1
- commit;
- /*ryazanova---Ispravit' nazvanija zadach IRG (6780)*/
- update task t
- set t.name = (select t1.name from task t1 where t1.id = t.parentid) || ' (' || t.irg_name || ')'
- where t.is_isolated = 1 and t.irg_name <> '';
- commit;
- /*-------------------------------------------------------------------------------------------------------------------------------*/
- /*ryazanova: derevo podrazdelenij v obratnom porjadke*/
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE get_backward_tree (
- dep_id integer)
- returns (
- o_id integer)
- as
- DECLARE VARIABLE L_K SMALLINT;
- begin
- O_ID = :dep_id;
- suspend;
- for SELECT PARENTID
- FROM department d
- WHERE ID = :dep_id and isdeleted = 0
- INTO :O_ID
- do
- begin
- for SELECT o_id
- FROM get_backward_tree (:O_ID)
- INTO :O_ID
- do
- suspend;
- end
- end
- ^
- SET TERM ; ^
- commit;
- /*-------------------------------------------------------------------------------------------------------------------------------*/
- /* Ryazanova - На ботов полномочия не удалять*/
- SET TERM ^ ;
- CREATE OR ALTER TRIGGER EMPLOYER_AU0 FOR EMPLOYER
- ACTIVE AFTER UPDATE POSITION 0
- as
- declare variable bossid integer;
- declare variable fbossid integer;
- declare variable projid integer;
- declare variable flag integer;
- declare variable l_empid integer;
- declare variable l_isdeleted integer;
- declare variable l_enabled smallint;
- declare variable l_parentid integer;
- begin
- if (new.isdeleted = 1 and old.isdeleted = 0) then
- begin
- /* for select id_boss
- from permission
- where id_employer = new.id and
- enabled >0
- into :l_empid
- do
- begin
- select isdeleted from employer where id = :l_empid
- into :l_isdeleted;
- if (l_isdeleted=0) then
- execute procedure set_permission_dep (l_empid, new.id);
- end */
- update permission
- set enabled=0
- where id_boss=new.id;
- /* update permission
- set enabled=0
- where id_employer=new.id; */
- /* Удаляем из всех пользовательских деревьев */
- delete from ud_employer where id_employer=new.id;
- end
- if (new.isdeleted = 0 and old.isdeleted=1) then
- execute procedure convertpermissions (new.id, new.isboss);
- if (new.id_department != old.id_department) then
- begin
- for select distinct t.id_project
- from grouptask gt
- left join task t on (gt.id_task=t.id)
- where gt.id_employer = old.id and gt.is_respperson=1
- into :projid
- do
- begin
- flag = null;
- select count(id_project) from PROJECT_DEP
- where id_Project = :projid and ID_Department = new.id_department
- into :flag; /*проверяем не привязан ли уже этот проект к новому подразделению*/
- if ((flag is null) or (flag = 0)) then /*если нет, то привязываем*/
- insert into PROJECT_DEP (ID_Project, ID_Department)
- values (:projid,new.id_department);
- flag = null;
- /* old begin */
- /* select count (t.id) --проверяем остались ли еще задачи для этого проекта в старом подразделении
- from task t
- join employer e on t.id_employer = e.id
- where t.id_project =:projid and
- t.ID_employer != old.id and
- e.id_department = old.id_department
- into :flag;
- */ /* old end */
- /* new begin */
- select count (t.id) /*проверяем остались ли еще задачи для этого проекта в старом подразделении*/
- from task t
- join grouptask gt on (t.id = gt.id_task and gt.is_worker = 1)
- join employer e on gt.id_employer = e.id
- where t.id_project =:projid and
- gt.ID_employer != old.id and
- e.id_department = old.id_department
- into :flag;
- /* new end */
- if ((flag is null) or (flag = 0)) then /*если нет, то удаляем привязку этого проекта к подразделению*/
- delete from PROJECT_DEP where
- id_project = :projid and
- id_department = old.id_department;
- end
- update permission
- set enabled = 0
- where id_boss = new.id and
- is_manual=0;
- execute procedure convertpermissions (new.id, new.isboss);
- select parentid from employer where id = new.id
- into :l_parentid;
- /*Обновляем deppermission для боссов данного пользователя*/
- for select id_boss,enabled
- from permission
- where id_employer = new.id and
- enabled <> 0
- into :l_empid,:l_enabled
- do
- begin
- select isdeleted from employer where id = :l_empid
- into :l_isdeleted;
- if (l_isdeleted = 0) then
- begin
- /* Проверяем имеет ли начальник права на отдел в который перевели чела
- * и если нет, то удаляем права начальника на чела
- */
- if (not (exists(select d.enabled
- from deppermission d
- where d.id_employer=:l_empid and
- d.id_department = new.id_department and
- d.enabled = :l_enabled)) and :l_empid <> :l_parentid) then
- delete from permission p
- where p.id_boss = :l_empid and
- p.id_employer = new.id;
- else
- execute procedure set_permission_dep (l_empid, new.id);
- /*Проверяем старое подразделение и удаляем его из deppermission, если там
- больше нет пользователей, на которых босс имеет права*/
- if (not exists(select p.id_boss
- from permission p
- join employer e on e.id = p.id_employer
- where e.id_department = old.id_department and
- p.id_boss = :l_empid and
- enabled = :l_enabled)) then
- begin
- delete from deppermission
- where id_department = old.id_department and
- id_employer = :l_empid and
- enabled = :l_enabled;
- end
- end
- end
- end
- if (old.isboss <> new.isboss) then /*смена статуса сотрудника, переделываем полномочия*/
- execute procedure convertpermissions (new.id, new.isboss);
- if (old.pass <> new.pass and old.needpasswordchange = new.needpasswordchange) then
- update employer
- set needpasswordchange = 0
- where id = new.id;
- if (old.name<>new.name or
- old.isboss<>new.isboss or
- old.login<>new.login or
- old.pass<>new.pass or
- old.isdeleted<>new.isdeleted or
- old.email<>new.email or
- old.cphone<>new.cphone or
- old.workphone<>new.workphone or
- old.birthdate<>new.birthdate or
- old.postaddress<>new.postaddress or
- old.homephone<>new.homephone or
- old.cphone2<>new.cphone2 or
- old.commnt<>new.commnt or
- old.manpost<>new.manpost or
- old.fastlogin<>new.fastlogin or
- old.awayto<>new.awayto
- ) then
- update employer
- set name = new.name,
- isboss = new.isboss,
- login = new.login,
- pass = new.pass,
- isdeleted = new.isdeleted,
- email = new.email,
- cphone = new.cphone,
- workphone = new.workphone,
- birthdate = new.birthdate,
- postaddress = new.postaddress,
- homephone = new.homephone,
- cphone2 = new.cphone2,
- commnt = new.commnt,
- manpost = new.manpost,
- fastlogin = new.fastlogin,
- awayto=new.awayto
- where parentid = new.id and
- isdeleted = 0;
- end^
- SET TERM ; ^
- commit;
- /*-------------------------------------------------------------------------------------------------------------------------------*/
- /* Priznak dostupa */
- EXECUTE PROCEDURE ADD_FIELD_IF_DOES_NOT_EXIST('EMPLOYER', 'ACCESS_TOKEN', 'VARCHAR(32)');
- RESULT
- =======
- 1
- commit;
- /* Srok deystviya priznaka dostupa */
- EXECUTE PROCEDURE ADD_FIELD_IF_DOES_NOT_EXIST('EMPLOYER', 'EXPIRE_DATE', 'TIMESTAMP');
- RESULT
- =======
- 1
- commit;
- /*--------------------------------------------------------------------------------------------------*/
- /*stasy - prava na proekty nachalo*/
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE GETPROJECT (
- i_id_employer integer,
- i_show_doc_projects smallint)
- returns (
- o_id integer,
- o_name varchar(200),
- o_description varchar(2000),
- o_startdate timestamp,
- o_enddate timestamp,
- o_depname varchar(2000))
- as
- begin
- if (i_show_doc_projects = 1) then
- begin
- for select distinct d.name,
- p.id,
- p.name,
- p.description,
- p.startdate,
- p.enddate
- from project p
- join department d on (p.id_department = d.id)
- left join task t on (p.id = t.id_project)
- where
- p.isdeleted =0
- and p.state = 0
- --and p.id_document is null
- and
- (
- p.id_author in (select id_employer from permission where id_boss = :i_id_employer and enabled=1)
- or
- t.id in
- (select distinct g.id_task
- from grouptask g
- join task t on t.id=g.id_task
- where g.id_original in
- (select id_employer from permission where id_boss = :i_id_employer and enabled=1)
- and t.isdeleted=0
- and t.is_checkpoint is null
- and (t.issecret=0 or g.id_task in (select id_task from grouptask where id_original = :i_id_employer)))
- )
- into :O_DEPNAME,
- :O_ID,
- :O_NAME,
- :O_DESCRIPTION,
- :O_STARTDATE,
- :O_ENDDATE
- do
- suspend;
- end
- else
- begin
- for select distinct d.name,
- p.id,
- p.name,
- p.description,
- p.startdate,
- p.enddate
- from project p
- join department d on (p.id_department = d.id)
- left join task t on (p.id = t.id_project)
- where
- p.isdeleted =0
- and p.state = 0
- and p.id_document is null
- and
- (
- p.id_author in (select id_employer from permission where id_boss = :i_id_employer and enabled=1)
- or
- t.id in
- (select distinct g.id_task
- from grouptask g
- join task t on t.id=g.id_task
- where g.id_original in
- (select id_employer from permission where id_boss = :i_id_employer and enabled=1)
- and t.isdeleted=0
- and t.is_checkpoint is null
- and (t.issecret=0 or g.id_task in (select id_task from grouptask where id_original = :i_id_employer)))
- )
- into :O_DEPNAME,
- :O_ID,
- :O_NAME,
- :O_DESCRIPTION,
- :O_STARTDATE,
- :O_ENDDATE
- do
- suspend;
- end
- end^
- Statement failed, SQLCODE = -206
- Dynamic SQL Error
- -SQL error code = -206
- -Column unknown
- -T.IS_CHECKPOINT
- -At line 39, column 20
- At line 5683 in file /tmp/patch_db/script
- SET TERM ; ^
- commit;
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE GETPROJECTARCHIVE (
- i_id_employer integer)
- returns (
- o_id integer,
- o_name varchar(200),
- o_description varchar(2000),
- o_startdate timestamp,
- o_enddate timestamp,
- o_depname varchar(2000))
- as
- begin
- for select distinct p.id,
- p.name,
- p.description,
- p.startdate,
- p.enddate,
- d.name
- from project p
- join department d on (p.id_department = d.id)
- left join task t on (p.id = t.id_project)
- where
- p.isdeleted =0
- and p.state = 1
- and
- (
- p.id_author in (select id_employer from permission where id_boss = :i_id_employer and enabled=1)
- or
- t.id in
- (select distinct g.id_task
- from grouptask g
- join task t on t.id=g.id_task
- where g.id_original in
- (select id_employer from permission where id_boss = :i_id_employer and enabled=1)
- and t.isdeleted=0
- and t.is_checkpoint is null
- and (t.issecret=0 or g.id_task in (select id_task from grouptask where id_original = :i_id_employer)))
- )
- into :O_ID,
- :O_NAME,
- :O_DESCRIPTION,
- :O_STARTDATE,
- :O_ENDDATE,
- :O_DEPNAME
- do
- suspend;
- end^
- Statement failed, SQLCODE = -206
- Dynamic SQL Error
- -SQL error code = -206
- -Column unknown
- -T.IS_CHECKPOINT
- -At line 36, column 20
- At line 5868 in file /tmp/patch_db/script
- SET TERM ; ^
- commit;
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE GETNAVIGATIONTREE_PROJ (
- i_id_employer integer,
- i_is_show_archive_projects smallint)
- returns (
- id integer,
- name varchar(200),
- description varchar(2000),
- state smallint,
- color varchar(16),
- is_mark_by_color smallint)
- as
- declare variable l_mydepid integer;
- BEGIN
- select ID_Department from employer where id=:I_ID_EMPLOYER into :L_MYDEPID;
- for select distinct p.id,
- p.name,
- p.description,
- p.state,
- p.color,
- p.is_mark_by_color
- from project p
- left join task t on (p.id = t.id_project)
- where
- p.isdeleted =0
- and (p.state = 0 or p.state = :i_is_show_archive_projects)
- and
- (
- p.id_author in (select id_employer from permission where id_boss = :i_id_employer and enabled=1)
- or
- t.id in
- (select distinct g.id_task
- from grouptask g
- join task t on t.id=g.id_task
- where g.id_original in
- (select id_employer from permission where id_boss = :i_id_employer and enabled=1)
- and t.isdeleted=0
- and t.is_checkpoint is null
- and (t.issecret=0 or g.id_task in (select id_task from grouptask where id_original = :i_id_employer)))
- )
- INTO :ID,
- :NAME,
- :DESCRIPTION,
- :STATE,
- :color,
- :is_mark_by_color
- DO
- BEGIN
- SUSPEND;
- END
- END^
- Statement failed, SQLCODE = -206
- Dynamic SQL Error
- -SQL error code = -206
- -Column unknown
- -T.IS_CHECKPOINT
- -At line 37, column 20
- At line 5975 in file /tmp/patch_db/script
- SET TERM ; ^
- commit;
- /*stasy - prava na proekty conec*/
- /* Добавление домена если такового еще нет.*/
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE CREATE_DOMAIN_IF_NOT_EXIST (
- domain_name varchar(100),
- sql_param_str varchar(300))
- as
- declare variable is_exist varchar(200);
- BEGIN
- SELECT RDB$FIELD_NAME FROM RDB$FIELDS WHERE UPPER( RDB$FIELD_NAME) = UPPER(:domain_name)
- INTO :is_exist;
- if (is_exist is null) THEN
- BEGIN
- EXECUTE STATEMENT
- 'CREATE DOMAIN ' || UPPER(:domain_name)||' '|| :sql_param_str ;
- END
- END^
- SET TERM ; ^
- commit;
- GRANT EXECUTE ON PROCEDURE CREATE_DOMAIN_IF_NOT_EXIST TO SYSDBA;
- commit;
- /* Создаем новый домен для хранения ЭЦП документов,заменяем тип поля в documents.signature*/
- EXECUTE PROCEDURE CREATE_DOMAIN_IF_NOT_EXIST ('BLOB_4096', 'AS BLOB SUB_TYPE 1 SEGMENT SIZE 4096 CHARACTER SET WIN1251');
- commit;
- update RDB$RELATION_FIELDS set RDB$FIELD_SOURCE = 'BLOB_4096', RDB$COLLATION_ID = 0 where (RDB$FIELD_NAME = 'SIGNATURE') and (RDB$RELATION_NAME = 'DOCUMENTS');
- commit;
- SET TERM ^ ;
- /*меняем строчку в вычислении признака issecretary - не учитывались псевдонимы*/
- create or alter procedure INFORMER2_GETMYTASKS (
- ID_EMPLOYER integer,
- ATASKID integer,
- MINTASKID integer)
- returns (
- TASKID integer,
- TASKNAME varchar(2000),
- ISVIEWED smallint,
- ISGROUP smallint,
- ISNEWMESSAGES smallint,
- AMIAUTHOR smallint,
- PRJID integer,
- ISREPORTED smallint,
- AUTHORID integer,
- EMPID integer,
- ISREJECTED smallint,
- ISWITHREPORT smallint,
- LASTACTID integer,
- TASKDESC varchar(10000),
- STARTDATE timestamp,
- ENDDATE timestamp,
- ACTCOUNT integer,
- ATT varchar(24000),
- TASK_TYPE smallint,
- ORDERTYPE smallint,
- DOCUMENTID integer,
- PRIORITY smallint,
- LASTACTDATE timestamp,
- EMPSID varchar(5000),
- DEPPATH varchar(2000),
- STATE smallint,
- LASTACT varchar(10000),
- LASTACTEMPID integer,
- ISONLYFORVIEW smallint,
- USERID integer,
- MYCOLOR smallint,
- SEND_ACTIONS smallint,
- RECEIVE_MAIL smallint,
- RECEIVE_SMS smallint,
- ACOUNT integer,
- LASTACOUNT integer,
- DOCUMENTNAME varchar(1000),
- DOCUMENTTYPEID integer,
- ISRESOLUTION smallint,
- ID_REALAUTHOR integer,
- ID_TASKINITIATOR integer,
- DOCVERSION integer,
- BTN varchar(200),
- PARENTID integer,
- SHOWDATE timestamp,
- IDFOLDER integer,
- ISSECRETARY smallint,
- ISCONTROL smallint,
- CTRLSID varchar(2000),
- SIGNSID varchar(2000),
- IS_HAVE_ISOLATED smallint,
- SYSACTCOUNT integer,
- MEANSACTCOUNT integer,
- ID_CHECKPOINT integer,
- ID_META_DICTIONARY integer,
- NRECORD_TASKTYPE integer,
- AUTHORSID varchar(2000),
- MAINEMPSID varchar(2000),
- NUMERATOR varchar(100),
- ISSECRET smallint,
- NEWACTCOUNT integer,
- IS_COMMITED smallint,
- CTRLID integer,
- ID_LAST_VIEWED_ACT integer,
- LASTCHANGE timestamp,
- ISUSEPARENTDOCS smallint,
- IS_SHOW_TASK smallint)
- as
- declare variable GT_LASTCHANGE timestamp;
- declare variable TA_LASTCHANGE timestamp;
- declare variable I integer;
- declare variable CNT integer;
- declare variable EXECDOCUMENTID varchar(1000);
- declare variable L_ISHIDDEN integer;
- declare variable SID integer;
- begin
- for select TASKID, TASKNAME, ISGROUP,
- AMIAUTHOR, PRJID, IsReported,
- /* AuthorId, EmpId, */IsRejected, IsWithReport,
- taskdesc, startdate, enddate, task_type,
- documentid, priority, deppath, state, IsOnlyForView, UserId, Send_Actions,
- ExecDocumentId, ID_REALAUTHOR, ID_TASKINITIATOR, PARENTID, is_have_isolated, id_checkpoint
- , id_meta_dictionary, nrecord_tasktype,numerator
- from Informer2_Getmytasks1(:ID_EMPLOYER, :ATASKID)
- into :TASKID, :TASKNAME, :ISGROUP,
- :AMIAUTHOR, :PRJID, :IsReported,
- /* :AuthorId, :EmpId,*/ :IsRejected, :IsWithReport,
- :taskdesc, :startdate, :enddate, :task_type,
- :documentid, :priority, :deppath, :state, :IsOnlyForView, :UserId, :Send_Actions,
- :ExecDocumentId, :ID_REALAUTHOR, :ID_TASKINITIATOR,:PARENTID, :is_have_isolated, :id_checkpoint
- ,:id_meta_dictionary, :nrecord_tasktype,:numerator
- do
- if (TaskId=ATaskId or TaskId>MinTaskId)
- then begin
- if (DocumentId is null and ExecDocumentId is null) then OrderType=0;
- else
- if (DocumentId is not null) then OrderType=1;
- else
- if (ExecDocumentId is not null)
- then begin
- OrderType=2;
- DocumentId=ExecDocumentId;
- end
- ISNEWMESSAGES=0;
- EXECUTE PROCEDURE informer2_gettaskids(ID_EMPLOYER, TASKID, IsOnlyForView) returning_values :EMPSID, :CTRLSID, :SIGNSID,
- :AuthorId, :EmpId , :AUTHORSID , :MAINEMPSID, :CTRLID;
- LastActDate=NULL;
- LastActId=-1;
- LastActId=-1;
- ActCount=0;
- LASTACT='';
- LASTACTEMPID=-1;
- idfolder=0;
- newactcount=0;
- MyColor=NULL;
- cnt=NULL;
- select ta.marker_color, ta.count_actions_view, ta.is_view_new_actions, ta.Id_last_viewed_action
- from task_attributes ta
- where ta.id_employer=:id_employer and
- ta.id_task=:taskid
- into :mycolor, :cnt, :ISNEWMESSAGES, :Id_last_viewed_act;
- select o_result
- from CheckTaskViewed(:ID_EMPLOYER, :taskid)
- into :isviewed;
- select t.la_id, t.action_count, t.sysaction_count, t.meansaction_count, t.issecret, t.isuseparentdocs
- from Task t
- where id= :TaskId
- into :LastActId, :ActCount, :sysactcount, :meansactcount, :issecret, :isuseparentdocs;
- if (isuseparentdocs=1) then
- begin
- SELECT O_DocumentID, O_DocumentName FROM getparentdocs(:TaskID)
- into :Documentid, :Documentname;
- end
- if (ActCount is null) then ActCount=0;
- ACount=ActCount;
- if ((ISNEWMESSAGES=1)or(ISNEWMESSAGES is null)or :ActCount=0)
- then ISNEWMESSAGES=0;
- else ISNEWMESSAGES=1;
- if (LastActId is null) then LastActId=0;
- if (LastActId>0) then
- begin
- select adate, Name, ID_Employer
- from Actions
- where id= :LastActId
- into :LastActDate, :LASTACT, :LASTACTEMPID;
- end
- execute procedure Informer2_TaskAtt(:taskid, -1, -1)
- returning_values :att;
- if (MyColor is null) then MyColor=0;
- select O_RECIVE_SMS, O_RECIVE_MAIL
- from GET_TASK_MAIL_SMS(:TaskId, :id_employer)
- into :receive_sms, :receive_mail;
- if (cnt is null) then lastacount=0;
- else lastacount=cnt;
- newactcount=acount-lastacount;
- isresolution=null;
- btn=null;
- select first 1 rt.isresolution, rt.button_caption from routetrees rt
- where rt.id_task = :taskid and
- rt.isvirtual = 0 and
- rt.isdeleted = 0 and
- (exists(select id from routenode rn
- where rn.id_routetree = rt.id and
- rn.id_employer = :id_employer and
- rn.isdeleted = 0))
- into :isresolution, :btn;
- if (isresolution is null) then isresolution=0;
- DocumentName='';
- DocumentTypeId=NULL;
- DocVersion=NULL;
- select Field1, ID_DocType, Doc_Version
- from Documents
- where id= :DocumentId
- into :DocumentName, :DocumentTypeId, :DocVersion;
- i=1;
- if (OrderType=1) then
- begin
- select O_result from documentcommited (:id_employer, :taskid)
- into :is_commited;
- if (is_commited=1) then
- if (not (exists(select first 1 id_task from grouptask where id_task=:TaskId and
- id_employer=:ID_employer and is_controler=1)))
- then i=0;
- end
- else is_commited=0;
- if (IsOnlyForView is null) then IsOnlyForView=0;
- if (IsOnlyForView=1) then
- begin
- /* SignsId=''; */
- if (exists (select first 1 id
- from Actions
- where id_task=:TaskId and
- examinated=1 and
- (id_employer= :id_employer or id_employer in (select O_EMPLOYERID from
- GETEMPLOYERALIASES(:id_employer)))
- ))
- then i=0;
- else begin
- i=1;
- end
- end
- /*if user needs information by the only one task,
- then return this task in any case*/
- if ((i=0) and (ATASKID<>-1)) then i=1;
- if (i=1) then
- begin
- showdate=NULL;
- select gt.show_task_date
- from grouptask gt
- where gt.id_task=:taskid and gt.id_employer=:id_employer
- into :showdate;
- ISSECRETARY=0;
- if (exists(select * from grouptask gr where gr.id_task=:TaskId
- AND GR.id_original=:id_employer and gr.is_shadow=1)) then
- ISSECRETARY=1;
- --повесит пережитком
- ISCONTROL=0;
- SELECT
- t.lastchange,
- ta.lastchange,
- gt.lastchange
- FROM
- task t
- left join task_attributes ta on (ta.id_task = t.id and ta.id_employer = :id_employer)
- left join grouptask gt on (gt.id_task = t.id and gt.id_employer = :id_employer)
- WHERE
- t.id = :taskid
- INTO
- :lastchange,
- :ta_lastchange,
- :gt_lastchange;
- if (:ta_lastchange > :lastchange) then
- begin
- lastchange = :ta_lastchange;
- end
- if (:gt_lastchange > :lastchange) then
- begin
- lastchange = :gt_lastchange;
- end
- is_show_task = 0;
- if (is_show_task = 0) then
- begin
- if (exists ( select
- first (1) gt.id_task
- from
- grouptask gt
- where
- gt.id_task = :taskid and
- (
- gt.id_original = :id_employer OR
- gt.id_original = (select parentid from employer where id = :id_employer)
- )
- and
- (
- gt.is_author = 1 OR
- gt.is_respperson = 1 OR
- gt.is_worker = 1 OR
- gt.is_controler = 1 OR
- gt.is_shadow = 1
- )
- )
- )
- then
- is_show_task = 1;
- if (is_show_task = 1) then
- if (exists( select
- first (1) gt.id_task
- from
- grouptask gt
- join task t on
- t.id = gt.id_task
- where
- gt.id_task = :taskid and
- t.is_isolated = 1 and
- (
- gt.id_original = :id_employer OR
- gt.id_original = (select parentid from employer where id = :id_employer)
- )
- and
- (
- gt.is_author = 1 OR
- gt.is_respperson = 1 OR
- gt.is_worker = 1 OR
- gt.is_controler = 1 OR
- gt.is_shadow = 1
- )
- and exists
- (
- select
- first (1) id_task
- from
- grouptask
- where
- id_task = (select parentid from task where id = :taskid) and
- (
- id_original = :id_employer OR
- id_original = (select parentid from employer where id = :id_employer)
- )
- and
- (
- is_author = 1 OR
- is_respperson = 1 OR
- is_worker = 1 OR
- is_controler = 1 OR
- is_shadow = 1
- )
- )
- )
- )
- then
- is_show_task = 0;
- end
- suspend;
- end
- end
- end^
- SET TERM ; ^
- commit;INSERT INTO SETTINGS (SETTINGS_KEY,SETTINGS_VALUE) VALUES ('version','1.4.18');
- update patch_info
- set paramvalue = 'OK'
- where paramname = 'PATCH_STATUS';
- update patch_info
- set paramvalue = '1.4.18'
- where paramname = 'CURRENT_VERSION';
- commit work;
- commit;
- commit work;
- Use CONNECT or CREATE DATABASE to specify a database
- CONNECT "/var/Motiw/db/motiw.fdb" USER 'SYSDBA' PASSWORD 'masterkey';
- SET NAMES WIN1251;
- update patch_info
- set paramvalue = 'Updates to 1.4.18'
- where paramname = 'PATCH_STATUS';
- update patch_info
- set paramvalue = cast(paramvalue as integer) + 1
- where paramname = 'PATCH_STEP';
- SET GENERATOR gen_patch_percent to 0;
- COMMIT WORK;
- /*-----------------------------------------------------------------------------------------------------------------------*/
- /* Ну и по традиции тут удаляем хлам и пережитки прошлой жизни */
- /*-----------------------------------------------------------------------------------------------------------------------*/
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE TMP_DROP_XLAM
- AS
- declare variable is_exist smallint;
- BEGIN
- SELECT result FROM IS_PROCEDURE_EXISTS('GETPERMREE_FOR_EMPLOYER_DOCINIT')
- INTO :is_exist;
- IF (is_exist = 1) THEN
- begin
- EXECUTE STATEMENT
- 'DROP PROCEDURE GETPERMREE_FOR_EMPLOYER_DOCINIT;';
- end
- SELECT result FROM IS_PROCEDURE_EXISTS('GETOPENTASKSFORREPORT4')
- INTO :is_exist;
- IF (is_exist = 1) THEN
- begin
- EXECUTE STATEMENT
- 'DROP PROCEDURE GETOPENTASKSFORREPORT4;';
- end
- SELECT result FROM IS_PROCEDURE_EXISTS('GETALLNOTICES')
- INTO :is_exist;
- IF (is_exist = 1) THEN
- begin
- EXECUTE STATEMENT
- 'DROP PROCEDURE GETALLNOTICES;';
- end
- END ^
- SET TERM ; ^
- commit;
- EXECUTE PROCEDURE TMP_DROP_XLAM;
- commit;
- DROP PROCEDURE TMP_DROP_XLAM;
- commit;
- /* добавляем шаблон задачи по умолчанию */
- EXECUTE PROCEDURE ADD_FIELD_IF_DOES_NOT_EXIST('EMPLOYER', 'TASK_TEMPLATE_DEFAULT', 'INTEGER');
- RESULT
- =======
- 1
- commit;
- /* право на создание задач (для проверки доступности кнопки создания задачи) */
- update menuitems set right_kind = 23
- where item_id = 101;
- commit;
- EXECUTE PROCEDURE ADD_FIELD_IF_DOES_NOT_EXIST('EMPLOYER', 'CAN_ADD_TASK', 'SMALLINT');
- RESULT
- =======
- 1
- commit;
- update employer set can_add_task = 1
- where can_add_task is null;
- commit;
- /*---------------------------------------------------------------------------------------*/
- /* stasy: Группы пользователей*/
- /*---------------------------------------------------------------------------------------*/
- /* Создаем таблицу EMP_GROUPS */
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE TMP_EMP_GROUPS_CREATE
- AS
- declare variable is_exist smallint;
- BEGIN
- /* Гарантируем генератор */
- SELECT result FROM IS_GENERATOR_EXISTS('GEN_EMP_GROUPS_ID')
- INTO :is_exist;
- IF (is_exist = 0) THEN
- BEGIN
- EXECUTE STATEMENT
- 'CREATE GENERATOR GEN_EMP_GROUPS_ID';
- END
- /* Гарантируем таблицу */
- SELECT result FROM IS_TABLE_EXISTS('EMP_GROUPS')
- INTO :is_exist;
- IF (is_exist = 0) THEN
- BEGIN
- EXECUTE STATEMENT
- 'CREATE TABLE EMP_GROUPS (
- ID_GROUP INTEGER NOT NULL,
- TITLE VARCHAR(200) NOT NULL,
- DISCRIPTION VARCHAR(1000),
- IS_DELITED SMALLINT,
- ID_OWNER INTEGER NOT NULL,
- iscommon SMALLINT,
- constraint PK_EMP_GROUPS_ID primary key (ID_GROUP))';
- END
- END ^
- SET TERM ; ^
- commit;
- EXECUTE PROCEDURE TMP_EMP_GROUPS_CREATE;
- commit;
- DROP PROCEDURE TMP_EMP_GROUPS_CREATE;
- commit;
- /* Создаем триггер для генерации ID */
- SET TERM ^;
- CREATE OR ALTER TRIGGER EMP_GROUPS_BI_GEN_ID
- FOR EMP_GROUPS
- ACTIVE BEFORE INSERT
- AS
- BEGIN
- IF (NEW.ID_GROUP IS NULL) THEN
- NEW.ID_GROUP = GEN_ID(GEN_EMP_GROUPS_ID, 1);
- END^
- SET TERM ; ^
- commit;
- /* раздаем гранты на таблицу */
- EXECUTE PROCEDURE GIVE_GRANTS_TO_ALL('TABLE','EMP_GROUPS','ALL');
- commit;
- /* Таблица EMPLOUEROFGROUP */
- /* Создаем таблицу EMPLOUEROFGROUP для связки таблиц EMP_GROUPS и employer (пользователь может находиться в нескольких группах) */
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE TMP_EMPLOYEROFGROUP_CREATE
- AS
- declare variable is_exist smallint;
- BEGIN
- /* Гарантируем таблицу */
- SELECT result FROM IS_TABLE_EXISTS('EMPLOYEROFGROUP')
- INTO :is_exist;
- IF (is_exist = 0) THEN
- BEGIN
- EXECUTE STATEMENT
- 'CREATE TABLE EMPLOYEROFGROUP (
- ID_EMP INTEGER NOT NULL,
- ID_GROUP INTEGER NOT NULL,
- PERMITION SMALLINT,
- IS_DELITED SMALLINT,
- constraint PK_EMPLOYEROFGROUP primary key (ID_EMP, ID_GROUP))';
- END
- END ^
- SET TERM ; ^
- commit;
- EXECUTE PROCEDURE TMP_EMPLOYEROFGROUP_CREATE;
- commit;
- DROP PROCEDURE TMP_EMPLOYEROFGROUP_CREATE;
- commit;
- /* раздаем гранты на таблицу */
- EXECUTE PROCEDURE GIVE_GRANTS_TO_ALL('TABLE','EMPLOYEROFGROUP','ALL');
- commit;
- /*создаем пункт меню группы пользователей*/
- EXECUTE PROCEDURE ADDMENUITEMBYTAG(868, 'L_GLOBAL_PERMISSIONS_GROUP', '/user/empgroup/', 'L_MENU_ADMINISTRATION', 8, 1, 6, NULL);
- commit;
- /*добавляем право на группы пользователей*/
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE GET_RIGHTS_OF_GROUP (
- i_id_employer integer,
- i_id_groupright integer)
- returns (
- o_right_kind integer,
- o_id_object integer,
- o_objectname varchar(1000),
- o_group_has_right smallint,
- o_can_edit smallint)
- as
- declare variable l_id_owner integer;
- declare variable l_id_groupright integer;
- begin
- O_ID_OBJECT = 0;
- O_OBJECTNAME = '';
- for select gl.id
- from grouprights_list gl
- into :O_RIGHT_KIND
- do
- begin
- select o_result from get_right_employer_and_group(:i_id_employer,:o_right_kind,0)
- into :o_can_edit;
- select o_result from get_right_groupright(:i_id_groupright,:o_right_kind,:o_id_object)
- into :o_group_has_right;
- suspend;
- end
- for select dt.id, dt.name, dt.id_owner from doctypes dt
- where dt.isdeleted=0
- into :o_id_object, :o_objectname, :l_id_owner
- do
- begin
- if (l_id_owner=i_id_employer or l_id_owner is null ) then
- o_can_edit = 1;
- else
- o_can_edit = 0;
- o_right_kind = 1;
- select o_result from get_right_groupright(:i_id_groupright,:o_right_kind,:o_id_object)
- into :o_group_has_right;
- suspend;
- o_right_kind = 2;
- select o_result from get_right_groupright(:i_id_groupright,:o_right_kind,:o_id_object)
- into :o_group_has_right;
- suspend;
- o_right_kind = 28; /* 28 - право выбора связанных документов */
- select o_result from get_right_groupright(:i_id_groupright,:o_right_kind,:o_id_object)
- into :o_group_has_right;
- suspend;
- end
- o_right_kind = 3;
- for select rt.id, rt.name, rt.id_owner from routetemplate rt
- where rt.isdeleted=0 and rt.kind=0
- into :o_id_object, :o_objectname, :l_id_owner
- do
- begin
- if (l_id_owner=i_id_employer or l_id_owner is null ) then
- o_can_edit = 1;
- else
- o_can_edit = 0;
- select o_result from get_right_groupright(:i_id_groupright,:o_right_kind,:o_id_object)
- into :o_group_has_right;
- suspend;
- end
- o_right_kind = 9;
- for select fd.id, fd.name, fd.id_owner from fdoctemplate fd
- where fd.isdeleted=0
- into :o_id_object, :o_objectname, :l_id_owner
- do
- begin
- if (l_id_owner=i_id_employer or l_id_owner is null ) then
- o_can_edit = 1;
- else
- o_can_edit = 0;
- select o_result from get_right_groupright(:i_id_groupright,:o_right_kind,:o_id_object)
- into :o_group_has_right;
- suspend;
- end
- o_right_kind = 12;
- for select it.id, it.name, it.id_owner from iwgtemplate it
- where it.isdeleted=0
- into :o_id_object, :o_objectname, :l_id_owner
- do
- begin
- if (l_id_owner=i_id_employer or l_id_owner is null ) then
- o_can_edit = 1;
- else
- o_can_edit = 0;
- select o_result from get_right_groupright(:i_id_groupright,:o_right_kind,:o_id_object)
- into :o_group_has_right;
- suspend;
- end
- o_right_kind = 10;
- if (I_ID_GROUPRIGHT is null) then L_ID_GROUPRIGHT=0;
- else
- L_ID_GROUPRIGHT=:I_ID_GROUPRIGHT;
- for select g.id, g.name, g.id_owner from grouprights g
- where g.isdeleted=0 and g.isvisible=1 and g.id<>:L_ID_GROUPRIGHT
- into :o_id_object, :o_objectname, :l_id_owner
- do
- begin
- if (l_id_owner=i_id_employer ) then
- o_can_edit = 1;
- else
- o_can_edit = 0;
- select o_result from get_right_groupright(:i_id_groupright,:o_right_kind,:o_id_object)
- into :o_group_has_right;
- suspend;
- end
- o_right_kind = 15;
- o_can_edit = 1;
- for select md.id, md.name, md.id_owner
- from meta_dictionary md
- where md.isdeleted=0 and md.id_owner=:i_id_employer and recordtype=1
- into :o_id_object, :o_objectname, :l_id_owner
- do
- begin
- select o_result from get_right_groupright(:i_id_groupright,:o_right_kind,:o_id_object)
- into :o_group_has_right;
- suspend;
- end
- /* 17 права на просмотр записей в справочнике */
- /* 18 права на добавление записей в справочник */
- /* 19 права на изменение записей в справочнике */
- /* 20 права на удаление записей в справочнике */
- o_can_edit = 1;
- for select md.id, md.name, md.id_owner
- from meta_dictionary md
- where md.isdeleted=0 and md.id_owner=:i_id_employer and recordtype=0
- into :o_id_object, :o_objectname, :l_id_owner
- do
- begin
- o_right_kind = 17;
- select o_result from get_right_groupright(:i_id_groupright,:o_right_kind,:o_id_object)
- into :o_group_has_right;
- suspend;
- o_right_kind = 18;
- select o_result from get_right_groupright(:i_id_groupright,:o_right_kind,:o_id_object)
- into :o_group_has_right;
- suspend;
- o_right_kind = 19;
- select o_result from get_right_groupright(:i_id_groupright,:o_right_kind,:o_id_object)
- into :o_group_has_right;
- suspend;
- o_right_kind = 20;
- select o_result from get_right_groupright(:i_id_groupright,:o_right_kind,:o_id_object)
- into :o_group_has_right;
- suspend;
- end
- o_right_kind = 22;
- for select tt.id, tt.name, tt.id_owner from task_templates tt
- into :o_id_object, :o_objectname, :l_id_owner
- do
- begin
- if (l_id_owner=i_id_employer or l_id_owner is null ) then
- o_can_edit = 1;
- else
- o_can_edit = 0;
- select o_result from get_right_groupright(:i_id_groupright,:o_right_kind,:o_id_object)
- into :o_group_has_right;
- suspend;
- end
- -- плагины не привязвнные к типам
- o_right_kind = 77;
- for select plg.id, plg.name, plg.id_owner from plugins plg where plg.no_connect_to_type=1
- into :o_id_object, :o_objectname, :l_id_owner
- do
- begin
- if (l_id_owner=i_id_employer or l_id_owner is null ) then
- o_can_edit = 1;
- else
- o_can_edit = 0;
- select o_result from get_right_groupright(:i_id_groupright,:o_right_kind,:o_id_object)
- into :o_group_has_right;
- suspend;
- end
- /* 23 права на просмотр событий календаря */
- /* 24 права на добавление и редактирование событий в календарь */
- /* 25 полные права*/
- o_can_edit = 1;
- for select c.id, c.name, c.id_owner
- from calendars c
- where c.id_owner=:i_id_employer and is_system=0
- into :o_id_object, :o_objectname, :l_id_owner
- do
- begin
- o_right_kind = 23;
- select o_result from get_right_groupright(:i_id_groupright,:o_right_kind,:o_id_object)
- into :o_group_has_right;
- suspend;
- o_right_kind = 24;
- select o_result from get_right_groupright(:i_id_groupright,:o_right_kind,:o_id_object)
- into :o_group_has_right;
- suspend;
- o_right_kind = 25;
- select o_result from get_right_groupright(:i_id_groupright,:o_right_kind,:o_id_object)
- into :o_group_has_right;
- suspend;
- end
- o_right_kind = 26;
- select o_result from get_right_groupright(:i_id_groupright,:o_right_kind,0)
- into :o_group_has_right;
- suspend;
- /* 27 права на общедоступные группы внешних пользователей */
- for select eeg.id, eeg.name, eeg.id_owner from email_employer_group eeg
- where eeg.isdeleted=0 and eeg.iscommon=1
- into :o_id_object, :o_objectname, :l_id_owner
- do
- begin
- if (l_id_owner=i_id_employer or l_id_owner is null ) then
- o_can_edit = 1;
- else
- o_can_edit = 0;
- o_right_kind = 27;
- select o_result from get_right_groupright(:i_id_groupright,:o_right_kind,:o_id_object)
- into :o_group_has_right;
- suspend;
- end
- /* 29 - права на группы пользователей*/
- for select eeg.id_group, eeg.title, eeg.id_owner from EMP_GROUPS eeg
- where eeg.IS_DELITED=0
- into :o_id_object, :o_objectname, :l_id_owner
- do
- begin
- if (l_id_owner=i_id_employer or l_id_owner is null ) then
- o_can_edit = 1;
- else
- o_can_edit = 0;
- o_right_kind = 29;
- select o_result from get_right_groupright(:i_id_groupright,:o_right_kind,:o_id_object)
- into :o_group_has_right;
- suspend;
- end
- end^
- SET TERM ; ^
- COMMIT;
- /*процедура возвращает системные права пользователей - так, как если бы он создавался
- ** сотрудник - полное право на себя
- ** начальник - полное право на свой отдел и подчиненные
- ** - только свои задачи на начальников и делопроизводителей одного уровня
- ** делопроиз - только свои задачи на свой отдел и подчиненные
- ** - начальников и делопроизводителей одного уровня*/
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE GET_SISTEM_PERM (
- i_id integer)
- returns (
- o_emp integer,
- o_right integer)
- as
- declare variable l_boss integer;
- declare variable l_depid integer;
- declare variable l_empid integer;
- declare variable l_isboss integer;
- declare variable l_mydepid integer;
- declare variable l_myparentdepid integer;
- declare variable l_parentdepid integer;
- BEGIN
- /*проверяем кем является чувак и выбираем его подразделение*/
- select e.isboss, e.id_department from employer e where e.id = :i_id
- into :l_boss, :L_MYDEPID;
- if (:l_boss = 0) then exit;/*если просто сотрудник - то выходим*/
- /*получаем родительское подразделение*/
- select parentid from department
- where id = :L_MYDEPID
- into :L_MYPARENTDEPID;
- /*получаем подразделение "для начальника"*/
- for select O_ID
- from GETTREE_FOR_BOSS (:i_id)
- into :L_DEPID
- do
- begin
- /*находим подразделения одного уровня*/
- select parentid
- from department
- where id=:L_DEPID
- into :L_PARENTDEPID;
- /*и проверяем там каждого сотрудника*/
- for select id, isboss
- from employer
- where isdeleted = 0 and
- id_department = :L_DEPID
- into :o_emp, :L_ISBOSS
- do
- begin /*если оного уровня, но не свое подразделения*/
- if ((:L_MYPARENTDEPID = :L_PARENTDEPID) and
- (:L_ISBOSS > 0) and
- (:L_DEPID <> :L_MYDEPID)) then
- begin/*тогда только свои задачи для начальников*/
- o_right = 2;
- suspend;
- end
- else /*если свое подразделение*/
- begin
- if ((:L_MYPARENTDEPID <> :L_PARENTDEPID) or (:L_DEPID = :L_MYDEPID) ) then
- begin
- if (:l_boss = 1) then
- begin
- o_right = 1;
- suspend;
- end
- else
- begin
- o_right = 2;
- suspend;
- end
- end
- end
- end
- end
- END^
- SET TERM ; ^
- COMMIT;
- /*---------------------------------------------------------------------------------------*/
- /* stasy: Группы пользователей - конец*/
- /*---------------------------------------------------------------------------------------*/
- /*---------------------------------------------------------------------------------------*/
- /* stasy: Задания по событиям - начало*/
- /*---------------------------------------------------------------------------------------*/
- /* 1.1 Создаем таблицу EVENTS_TYPES, в ней будет id события и тег */
- /*---------------------------------------------------------------------------------------*/
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE TMP_JOBS_TYPES_CREATE
- AS
- declare variable is_exist smallint;
- BEGIN
- /* Гарантируем таблицу */
- SELECT result FROM IS_TABLE_EXISTS('JOBS_TYPES')
- INTO :is_exist;
- IF (is_exist = 0) THEN
- BEGIN
- EXECUTE STATEMENT
- 'CREATE TABLE JOBS_TYPES (
- ID_TYPE INTEGER NOT NULL,
- TYPE_NAME VARCHAR(200) NOT NULL,
- constraint PK_JOBS_TYPES primary key (ID_TYPE))';
- END
- END ^
- SET TERM ; ^
- commit;
- EXECUTE PROCEDURE TMP_JOBS_TYPES_CREATE;
- commit;
- DROP PROCEDURE TMP_JOBS_TYPES_CREATE;
- commit;
- /*---------------------------------------------------------------------------------------*/
- /* 1.2 раздаем гранты на таблицу */
- /*---------------------------------------------------------------------------------------*/
- EXECUTE PROCEDURE GIVE_GRANTS_TO_ALL('TABLE','JOBS_TYPES','ALL');
- commit;
- /*---------------------------------------------------------------------------------------*/
- /* 1.3 к этому моменту в ней будет одно значение - "создать подзадачу по шаблону"*/
- /*---------------------------------------------------------------------------------------*/
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE TMP_JOBS_TYPES_INSERT
- AS
- declare variable is_exist smallint;
- BEGIN
- /*если еще пустая*/
- SELECT count(*) from JOBS_TYPES
- INTO :is_exist;
- IF (is_exist = 0) THEN
- BEGIN
- INSERT INTO JOBS_TYPES (ID_TYPE, TYPE_NAME) VALUES (1, 'L_SUB_TASK_BY_TEMPL');
- END
- END ^
- SET TERM ; ^
- commit;
- EXECUTE PROCEDURE TMP_JOBS_TYPES_INSERT;
- commit;
- DROP PROCEDURE TMP_JOBS_TYPES_INSERT;
- commit;
- /*---------------------------------------------------------------------------------------*/
- /* 2.1 Создаем таблицу jobs, в ней будет: локальный id, тип задания и ид задания */
- /*---------------------------------------------------------------------------------------*/
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE TMP_JOBS_CREATE
- AS
- declare variable is_exist smallint;
- BEGIN
- /* Гарантируем генератор */
- SELECT result FROM IS_GENERATOR_EXISTS('GEN_JOB_ID')
- INTO :is_exist;
- IF (is_exist = 0) THEN
- BEGIN
- EXECUTE STATEMENT
- 'CREATE GENERATOR GEN_JOB_ID';
- END
- /* Гарантируем таблицу */
- SELECT result FROM IS_TABLE_EXISTS('JOBS')
- INTO :is_exist;
- IF (is_exist = 0) THEN
- BEGIN
- EXECUTE STATEMENT
- 'CREATE TABLE JOBS (
- ID_JOB_LIST INTEGER,
- ID_JOB INTEGER NOT NULL,
- ID_JOB_TYPE INTEGER NOT NULL,
- constraint PK_JOBS primary key (ID_JOB))';
- END
- END ^
- SET TERM ; ^
- commit;
- EXECUTE PROCEDURE TMP_JOBS_CREATE;
- commit;
- DROP PROCEDURE TMP_JOBS_CREATE;
- commit;
- /*---------------------------------------------------------------------------------------*/
- /* 2.2 Создаем триггер для генерации ID */
- /*---------------------------------------------------------------------------------------*/
- SET TERM ^;
- CREATE OR ALTER TRIGGER JOB_BI_GEN_ID
- FOR JOBS
- ACTIVE BEFORE INSERT
- AS
- BEGIN
- IF (NEW.ID_JOB IS NULL) THEN
- NEW.ID_JOB = GEN_ID(GEN_JOB_ID, 1);
- END^
- SET TERM ; ^
- commit;
- /*---------------------------------------------------------------------------------------*/
- /* 2.3 раздаем гранты на таблицу */
- /*---------------------------------------------------------------------------------------*/
- EXECUTE PROCEDURE GIVE_GRANTS_TO_ALL('TABLE','JOBS','ALL');
- commit;
- /*---------------------------------------------------------------------------------------*/
- /* 3.1 Создаем таблицу job_list, в ней будет: ид из Joba и из связки */
- /*---------------------------------------------------------------------------------------*/
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE TMP_JOB_LIST_CREATE
- AS
- declare variable is_exist smallint;
- BEGIN
- /* Гарантируем генератор */
- SELECT result FROM IS_GENERATOR_EXISTS('GEN_JOB_LIST_ID')
- INTO :is_exist;
- IF (is_exist = 0) THEN
- BEGIN
- EXECUTE STATEMENT
- 'CREATE GENERATOR GEN_JOB_LIST_ID';
- END
- /* Гарантируем таблицу */
- SELECT result FROM IS_TABLE_EXISTS('JOB_LIST')
- INTO :is_exist;
- IF (is_exist = 0) THEN
- BEGIN
- EXECUTE STATEMENT
- 'CREATE TABLE JOB_LIST (
- ID_JOB_LIST INTEGER NOT NULL,
- NAME VARCHAR(200) NOT NULL,
- ID_OWNER INTEGER NOT NULL,
- constraint PK_JOB_LIST primary key (ID_JOB_LIST))';
- END
- END ^
- SET TERM ; ^
- commit;
- EXECUTE PROCEDURE TMP_JOB_LIST_CREATE;
- commit;
- DROP PROCEDURE TMP_JOB_LIST_CREATE;
- commit;
- /*---------------------------------------------------------------------------------------*/
- /* 3.2 Создаем триггер для генерации ID */
- /*---------------------------------------------------------------------------------------*/
- SET TERM ^;
- CREATE OR ALTER TRIGGER JOB_LIST_BI_GEN_ID
- FOR JOB_LIST
- ACTIVE BEFORE INSERT
- AS
- BEGIN
- IF (NEW.ID_JOB_LIST IS NULL) THEN
- NEW.ID_JOB_LIST = GEN_ID(GEN_JOB_LIST_ID, 1);
- END^
- SET TERM ; ^
- commit;
- /*---------------------------------------------------------------------------------------*/
- /* 3.3 раздаем гранты на таблицу */
- /*---------------------------------------------------------------------------------------*/
- EXECUTE PROCEDURE GIVE_GRANTS_TO_ALL('TABLE','JOB_LIST','ALL');
- commit;
- /*---------------------------------------------------------------------------------------*/
- /* 4.1 Создаем таблицу jobs_object, в ней будет: локальный id, тип объекта, его ид и ид задания */
- /*---------------------------------------------------------------------------------------*/
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE TMP_JOBS_OBJECT_CREATE
- AS
- declare variable is_exist smallint;
- BEGIN
- /* Гарантируем генератор */
- SELECT result FROM IS_GENERATOR_EXISTS('GEN_JOBS_OBJECT_ID')
- INTO :is_exist;
- IF (is_exist = 0) THEN
- BEGIN
- EXECUTE STATEMENT
- 'CREATE GENERATOR GEN_JOBS_OBJECT_ID';
- END
- /* Гарантируем таблицу */
- SELECT result FROM IS_TABLE_EXISTS('JOBS_OBJECT')
- INTO :is_exist;
- IF (is_exist = 0) THEN
- BEGIN
- EXECUTE STATEMENT
- 'CREATE TABLE JOBS_OBJECT (
- ID_JOBS_OBJECT INTEGER NOT NULL,
- ID_JOB INTEGER NOT NULL,
- ID_JOBS_OBJECT_TYPE INTEGER NOT NULL,
- ID_OBJECT INTEGER NOT NULL,
- constraint PK_JOBS_OBJECT primary key (ID_JOBS_OBJECT))';
- END
- END ^
- SET TERM ; ^
- commit;
- EXECUTE PROCEDURE TMP_JOBS_OBJECT_CREATE;
- commit;
- DROP PROCEDURE TMP_JOBS_OBJECT_CREATE;
- commit;
- /*---------------------------------------------------------------------------------------*/
- /* 4.2 Создаем триггер для генерации ID */
- /*---------------------------------------------------------------------------------------*/
- SET TERM ^;
- CREATE OR ALTER TRIGGER JOBS_OBJECT_BI_GEN_ID
- FOR JOBS_OBJECT
- ACTIVE BEFORE INSERT
- AS
- BEGIN
- IF (NEW.ID_JOBS_OBJECT IS NULL) THEN
- NEW.ID_JOBS_OBJECT = GEN_ID(GEN_JOBS_OBJECT_ID, 1);
- END^
- SET TERM ; ^
- commit;
- /*---------------------------------------------------------------------------------------*/
- /* 4.3 раздаем гранты на таблицу */
- /*---------------------------------------------------------------------------------------*/
- EXECUTE PROCEDURE GIVE_GRANTS_TO_ALL('TABLE','JOBS_OBJECT','ALL');
- commit;
- /*---------------------------------------------------------------------------------------*/
- /* В очередной раз становимся лучше. теперь так: для запускающих задание объектов одна таблица
- , различаем по типам - 1 - события, 2- задачи, дальше разберемся*/
- /*---------------------------------------------------------------------------------------*/
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE TMP_EVENT_JOBS_CREATE
- AS
- declare variable is_exist smallint;
- BEGIN
- SELECT result FROM IS_TABLE_EXISTS('JOBBERS')
- INTO :is_exist;
- IF (is_exist = 0) THEN
- BEGIN
- EXECUTE STATEMENT
- 'CREATE TABLE JOBBERS (
- ID_JOB_LIST INTEGER NOT NULL,
- ID_JOBBER INTEGER NOT NULL,
- ID_JOBBER_TYPE INTEGER NOT NULL,
- constraint PK_JOBBERS primary key (ID_JOB_LIST, ID_JOBBER, ID_JOBBER_TYPE))';
- END
- END ^
- SET TERM ; ^
- commit;
- EXECUTE PROCEDURE TMP_EVENT_JOBS_CREATE;
- commit;
- DROP PROCEDURE TMP_EVENT_JOBS_CREATE;
- commit;
- /*---------------------------------------------------------------------------------------*/
- /* раздаем гранты на таблицу */
- /*---------------------------------------------------------------------------------------*/
- EXECUTE PROCEDURE GIVE_GRANTS_TO_ALL('TABLE','JOBBERS','ALL');
- commit;
- /*---------------------------------------------------------------------------------------*/
- /* добавляем признак "Выполненное задание" в события */
- /*---------------------------------------------------------------------------------------*/
- EXECUTE PROCEDURE ADD_FIELD_IF_DOES_NOT_EXIST('CALENDAR_PERIODS', 'ISEXECT', 'SMALLINT');
- RESULT
- =======
- 1
- commit;
- /*---------------------------------------------------------------------------------------*/
- /* сбрасываем этот признак для событий, которые уже наступили*/
- /*---------------------------------------------------------------------------------------*/
- UPDATE CALENDAR_PERIODS SET ISEXECT = 1 WHERE START_DATE < 'NOW';
- commit;
- /*---------------------------------------------------------------------------------------*/
- /* stasy: Задания по событиям - конец*/
- /*---------------------------------------------------------------------------------------*/
- /*---------------------------------------------------------------------------------------*/
- /* stasy: Цепочки задач - начало*/
- /*---------------------------------------------------------------------------------------*/
- /*---------------------------------------------------------------------------------------*/
- /* добавляем поле для списков заданий в шаблоны задач */
- /*---------------------------------------------------------------------------------------*/
- EXECUTE PROCEDURE ADD_FIELD_IF_DOES_NOT_EXIST('TASK_TEMPLATES', 'ID_JOB_LIST', 'INTEGER');
- RESULT
- =======
- 1
- commit;
- /*---------------------------------------------------------------------------------------*/
- /* stasy: Цепочки задач - конец*/
- /*---------------------------------------------------------------------------------------*/
- /* Делаем процедуру, которая строит дерево инициаторов или контролеров типа документа в зависимости от параметра i_right_kind */
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE GETPERMREE_FOR_EMPLOYER_DOC (
- i_id integer,
- i_doctypeid integer,
- i_right_kind integer)
- returns (
- o_id integer,
- o_name varchar(200),
- o_level integer)
- as
- declare variable l_k smallint;
- declare variable l_empid integer;
- declare variable l_pred_level integer;
- begin
- l_k = 0;
- l_pred_level = 0;
- for select O_ID,O_NAME,O_LEVEL
- from GETPERMISSIONTREE_FOR_EMPLOYER (:i_id, 0)
- into :O_ID, :o_name, :o_level
- do
- begin
- l_k = 0;
- for select p.id_employer
- from permission p
- join employer e on e.id = p.id_employer
- where e.id_department=:o_id and p.id_boss=:i_id and p.enabled>0 and :l_k=0
- into :L_EMPID
- do
- begin
- if (exists(select grc.id_object
- from grouprights_content grc
- join GROUPRIGHTS_EMPLOYER gre on gre.id_groupright = grc.id_groupright
- where gre.id_employer = :L_EMPID and
- grc.right_kind=:i_right_kind and
- grc.id_object=:i_doctypeid)) then
- l_k=1;
- end
- if (l_k=1) then
- begin
- if (o_level - l_pred_level > 1) then
- o_level = o_level - 1;
- l_pred_level = o_level;
- suspend;
- end
- end
- end^
- SET TERM ; ^
- commit;
- EXECUTE PROCEDURE GIVE_GRANTS_TO_ALL('PROCEDURE','GETPERMREE_FOR_EMPLOYER_DOC','EXECUTE');
- commit;
- /* Признак "Скрывать при поиске" для полей типа задачи */
- EXECUTE PROCEDURE ADD_FIELD_IF_DOES_NOT_EXIST('META_FIELD', 'ISHIDEINSEARCH', 'SMALLINT');
- RESULT
- =======
- 1
- commit;
- /* Шаблон справочника */
- EXECUTE PROCEDURE ADD_FIELD_IF_DOES_NOT_EXIST('META_FIELD', 'DICTIONARY_TEMPLATE', 'VARCHAR(1000)');
- RESULT
- =======
- 1
- commit;
- /* Флаг необходимости смены пароля */
- EXECUTE PROCEDURE ADD_FIELD_IF_DOES_NOT_EXIST('EMPLOYER', 'NEEDPASSWORDCHANGE', 'SMALLINT');
- RESULT
- =======
- 1
- commit;
- /* Elena - Добавила сброс флага NEEDPASSWORDCHANGE при смене пароля*/
- SET TERM ^ ;
- CREATE OR ALTER TRIGGER EMPLOYER_AU0 FOR EMPLOYER
- ACTIVE AFTER UPDATE POSITION 0
- as
- declare variable bossid integer;
- declare variable fbossid integer;
- declare variable projid integer;
- declare variable flag integer;
- declare variable l_empid integer;
- declare variable l_isdeleted integer;
- declare variable l_enabled smallint;
- begin
- if (new.isdeleted = 1 and old.isdeleted = 0) then
- begin
- /* for select id_boss
- from permission
- where id_employer = new.id and
- enabled >0
- into :l_empid
- do
- begin
- select isdeleted from employer where id = :l_empid
- into :l_isdeleted;
- if (l_isdeleted=0) then
- execute procedure set_permission_dep (l_empid, new.id);
- end */
- update permission
- set enabled=0
- where id_boss=new.id;
- /* update permission
- set enabled=0
- where id_employer=new.id; */
- /* Удаляем из всех пользовательских деревьев */
- delete from ud_employer where id_employer=new.id;
- end
- if (new.isdeleted = 0 and old.isdeleted=1) then
- execute procedure convertpermissions (new.id, new.isboss);
- if (new.id_department != old.id_department) then
- begin
- for select distinct t.id_project
- from grouptask gt
- left join task t on (gt.id_task=t.id)
- where gt.id_employer = old.id and gt.is_respperson=1
- into :projid
- do
- begin
- flag = null;
- select count(id_project) from PROJECT_DEP
- where id_Project = :projid and ID_Department = new.id_department
- into :flag; /*проверяем не привязан ли уже этот проект к новому подразделению*/
- if ((flag is null) or (flag = 0)) then /*если нет, то привязываем*/
- insert into PROJECT_DEP (ID_Project, ID_Department)
- values (:projid,new.id_department);
- flag = null;
- /* old begin */
- /* select count (t.id) --проверяем остались ли еще задачи для этого проекта в старом подразделении
- from task t
- join employer e on t.id_employer = e.id
- where t.id_project =:projid and
- t.ID_employer != old.id and
- e.id_department = old.id_department
- into :flag;
- */ /* old end */
- /* new begin */
- select count (t.id) /*проверяем остались ли еще задачи для этого проекта в старом подразделении*/
- from task t
- join grouptask gt on (t.id = gt.id_task and gt.is_worker = 1)
- join employer e on gt.id_employer = e.id
- where t.id_project =:projid and
- gt.ID_employer != old.id and
- e.id_department = old.id_department
- into :flag;
- /* new end */
- if ((flag is null) or (flag = 0)) then /*если нет, то удаляем привязку этого проекта к подразделению*/
- delete from PROJECT_DEP where
- id_project = :projid and
- id_department = old.id_department;
- end
- update permission
- set enabled = 0
- where id_boss = new.id and
- is_manual=0;
- execute procedure convertpermissions (new.id, new.isboss);
- /*Обновляем deppermission для боссов данного пользователя*/
- for select id_boss,enabled
- from permission
- where id_employer = new.id and
- enabled <> 0
- into :l_empid,:l_enabled
- do
- begin
- select isdeleted from employer where id = :l_empid
- into :l_isdeleted;
- if (l_isdeleted = 0) then
- begin
- /* Проверяем имеет ли начальник права на отдел в который перевели чела
- * и если нет, то удаляем права начальника на чела
- */
- if (not (exists(select d.enabled
- from deppermission d
- where d.id_employer=:l_empid and
- d.id_department = new.id_department and
- d.enabled = :l_enabled))) then
- delete from permission p
- where p.id_boss = :l_empid and
- p.id_employer = new.id;
- else
- execute procedure set_permission_dep (l_empid, new.id);
- /*Проверяем старое подразделение и удаляем его из deppermission, если там
- больше нет пользователей, на которых босс имеет права*/
- if (not exists(select p.id_boss
- from permission p
- join employer e on e.id = p.id_employer
- where e.id_department = old.id_department and
- p.id_boss = :l_empid and
- enabled = :l_enabled)) then
- begin
- delete from deppermission
- where id_department = old.id_department and
- id_employer = :l_empid and
- enabled = :l_enabled;
- end
- end
- end
- end
- if (old.isboss <> new.isboss) then /*смена статуса сотрудника, переделываем полномочия*/
- execute procedure convertpermissions (new.id, new.isboss);
- if (old.pass <> new.pass and old.needpasswordchange = new.needpasswordchange) then
- update employer
- set needpasswordchange = 0
- where id = new.id;
- if (old.name<>new.name or
- old.isboss<>new.isboss or
- old.login<>new.login or
- old.pass<>new.pass or
- old.isdeleted<>new.isdeleted or
- old.email<>new.email or
- old.cphone<>new.cphone or
- old.workphone<>new.workphone or
- old.birthdate<>new.birthdate or
- old.postaddress<>new.postaddress or
- old.homephone<>new.homephone or
- old.cphone2<>new.cphone2 or
- old.commnt<>new.commnt or
- old.manpost<>new.manpost or
- old.fastlogin<>new.fastlogin or
- old.awayto<>new.awayto
- ) then
- update employer
- set name = new.name,
- isboss = new.isboss,
- login = new.login,
- pass = new.pass,
- isdeleted = new.isdeleted,
- email = new.email,
- cphone = new.cphone,
- workphone = new.workphone,
- birthdate = new.birthdate,
- postaddress = new.postaddress,
- homephone = new.homephone,
- cphone2 = new.cphone2,
- commnt = new.commnt,
- manpost = new.manpost,
- fastlogin = new.fastlogin,
- awayto=new.awayto
- where parentid = new.id and
- isdeleted = 0;
- end^
- SET TERM ; ^
- commit;
- /*-------------------------------------------------------------------------------------------------------------------------------*/
- /* пункт меню "Интеграция с LDAP" */
- /*-------------------------------------------------------------------------------------------------------------------------------*/
- EXECUTE PROCEDURE ADDMENUITEMBYTAG(869, 'L_MENU_LDAP', 'http://ldapsync_host:ldapsync_port', 'L_MENU_ADMINISTRATION', 21, 1, 6, NULL);
- commit;
- /* Elena - Добавила выходной параметр id_tasktype*/
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE GETTASKINFO4SF (
- idemployer integer,
- idtask integer)
- returns (
- taskid integer,
- tasknumber varchar(200),
- priority integer,
- taskname varchar(2000),
- startdate date,
- enddate date,
- author varchar(10000),
- controller varchar(10000),
- responsible varchar(10000),
- worker varchar(10000),
- projectname varchar(10000),
- tasktype varchar(10000),
- taskstate char(4),
- marker integer,
- id_tasktype integer)
- as
- declare variable is_author smallint;
- declare variable is_controller smallint;
- declare variable is_responsible smallint;
- declare variable is_worker smallint;
- declare variable emp_name varchar(2000);
- declare variable act_cnt integer;
- declare variable istasknew smallint;
- declare variable isactnew smallint;
- declare variable isreport smallint;
- declare variable isreject smallint;
- declare variable i integer;
- declare variable sql varchar(1000);
- BEGIN
- SQL = '';
- if (idtask<>-1) then
- begin
- SQL = ' and t.ID = ' || :idtask;
- end
- for EXECUTE STATEMENT 'select
- t.ID,
- lower(t.NUMERATOR),
- t.PRIORITY,
- lower(t.NAME),
- t.STARTDATE,
- t.ENDDATE,
- lower(p.NAME),
- lower(md.NAME),
- md.id,
- ta.MARKER_COLOR,
- t.action_count,
- (1 - gt.IS_VIEWED_TASK),
- (1-(case ta.IS_VIEW_NEW_ACTIONS when (ta.IS_VIEW_NEW_ACTIONS) then ta.IS_VIEW_NEW_ACTIONS else 0 end)),
- t.ISREPORTED,
- t.ISREJECTED
- from
- TASK t
- join GROUPTASK gt on
- t.ID = gt.ID_TASK
- join PROJECT p on
- p.id = t.ID_PROJECT
- join META_DICTIONARY md on
- md.ID = t.ID_META_DICTIONARY
- left join TASK_ATTRIBUTES ta on
- ta.ID_TASK = gt.ID_TASK and ta.id_employer=gt.id_original
- where
- gt.id_original = ' || :idemployer || ' and gt.task_state=0' || :SQL
- into
- :TASKID,
- :TASKNUMBER,
- :PRIORITY,
- :TASKNAME,
- :STARTDATE,
- :ENDDATE,
- :PROJECTNAME,
- :TASKTYPE,
- :ID_TASKTYPE,
- :MARKER,
- :ACT_CNT,
- :istasknew,
- :isactnew,
- :isreport,
- :isreject
- do
- begin
- Author = '';
- Controller = '';
- Responsible = '';
- Worker = '';
- for
- select
- gt.IS_AUTHOR,
- gt.IS_CONTROLER,
- gt.IS_RESPPERSON,
- gt.IS_WORKER,
- e.NAME
- from
- GROUPTASK gt
- join EMPLOYER e on
- e.ID = gt.ID_EMPLOYER
- where
- gt.ID_TASK = :TASKID
- into
- :is_author,
- :is_controller,
- :is_responsible,
- :is_worker,
- :emp_name
- do
- begin
- if (is_author = 1) then
- begin
- if (Author <> '') then Author = Author || ',';
- Author = Author || emp_name;
- end
- if (is_controller = 1) then
- begin
- if (Controller <> '') then Controller = Controller || ',';
- Controller = Controller || emp_name;
- end
- if (is_responsible = 1) then
- begin
- if (Responsible <> '') then Responsible = Responsible || ',';
- Responsible = Responsible || emp_name;
- end
- if (is_worker = 1) then
- begin
- if (Worker <> '') then Worker = Worker || ',';
- Worker = Worker || emp_name;
- end
- end
- if ( ( (ACT_CNT=0)or(ACT_CNT is null) ) ) then isactnew = 0;
- if (isreject is null) then isreject = 0;
- taskstate = istasknew || isactnew || isreport || isreject;
- SUSPEND;
- end
- END^
- SET TERM ; ^
- commit;
- /*-------------------------------------------------------------------------------------------------------------------------------*/
- /*stasy: shablon otobrajenia imeni documenta begining*/
- /*-------------------------------------------------------------------------------------------------------------------------------*/
- EXECUTE PROCEDURE ADD_FIELD_IF_DOES_NOT_EXIST('DOCTYPES', 'DISPLAY_NAME', 'VARCHAR(1000)');
- RESULT
- =======
- 1
- commit;
- /*-------------------------------------------------------------------------------------------------------------------------------*/
- /*shablon otobrajenia imeni documenta end*/
- /*-------------------------------------------------------------------------------------------------------------------------------*/
- /*tip resolucii - begin*/
- /*isnachalno nepravilno bilo, chishu*/
- /*-------------------------------------------------------------------------------------------------------------------------------*/
- delete from doccards where FIELDID = 'RESOLUTION_TYPE' and FIELDTYPE = 104;
- commit;
- /*-------------------------------------------------------------------------------------------------------------------------------*/
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE DROD_FIELD_IF_EXIST
- (
- table_name varchar(50),
- field_name varchar(50)
- )
- RETURNS
- (
- result SMALLINT
- )
- AS
- DECLARE VARIABLE is_exist SMALLINT;
- BEGIN
- result = 0;
- SELECT result FROM IS_FIELD_EXISTS(:table_name, :field_name)
- INTO :is_exist;
- IF (is_exist > 0) THEN
- BEGIN
- table_name = UPPER(table_name);
- field_name = UPPER(field_name);
- EXECUTE STATEMENT
- 'ALTER TABLE ' || table_name || ' DROP ' || field_name ;
- result = 1;
- END
- SUSPEND;
- END^
- SET TERM ; ^
- COMMIT;
- /*-------------------------------------------------------------------------------------------------------------------------------*/
- EXECUTE PROCEDURE DROD_FIELD_IF_EXIST('DOCCARDS', 'RESOLUTION_TYPE');
- RESULT
- =======
- 0
- commit;
- /*-------------------------------------------------------------------------------------------------------------------------------*/
- EXECUTE PROCEDURE ADD_FIELD_IF_DOES_NOT_EXIST('DOCTYPES', 'RESOLUTION_TYPE', 'INTEGER');
- RESULT
- =======
- 1
- commit;
- /*tip resolucii - end*/
- /*-------------------------------------------------------------------------------------------------------------------------------*/
- EXECUTE PROCEDURE ADD_INDEX_IF_DOES_NOT_EXIST('IDX_META_FIELD1','META_FIELD','NAME, ISDELETED');
- RESULT
- =======
- 1
- commit;
- EXECUTE PROCEDURE ADD_INDEX_IF_DOES_NOT_EXIST('DOCTYPES_IDX1', 'DOCTYPES', 'ISDELETED');
- RESULT
- =======
- 0
- commit;
- /*-----------------------------------------------------------------------------------------------------------------------------------------------*/
- /*01.03.2011, Alisa.Kot, task 270434
- /*-----------------------------------------------------------------------------------------------------------------------------------------------*/
- /*-----------------------------------------------------------------------------------------------------------------------------------------------*/
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE GETTASKEXECDOCBUTOUTDATE_1 (
- I_FROM_DATE Timestamp,
- I_TO_DATE Timestamp,
- I_ID_DEPARTMENT Integer )
- RETURNS (
- O_TASKID Integer,
- O_PROJID Integer,
- O_DOC_EXEC_ID Integer )
- AS
- begin
- for select t.id, t.id_project
- from task t
- where t.state = 1 and
- t.isdeleted = 0 and
- t.tsreport > t.enddate and
- t.id_department = :i_id_department and
- t.enddate between :i_from_date and :i_to_date and
- t.tsreport between :i_from_date and :i_to_date
- into :o_taskid, :O_PROJID
- do
- suspend;
- end^
- SET TERM ; ^
- commit;
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE GETTASKEXECDOCBUTOUTDATE (
- I_ID_EMPLOYER Integer,
- I_ID_DEPARTMENT Integer,
- I_ONLY_THIS_DEP Smallint,
- I_FROM_DATE Timestamp,
- I_TO_DATE Timestamp )
- RETURNS (
- O_TASK_NAME Varchar(2000),
- O_AUTHOR Varchar(2000),
- O_ADATE Timestamp,
- O_TASKID Integer,
- O_AUTHORID Integer,
- O_TASKENDDATE Timestamp,
- O_STATE Smallint,
- O_ACT_EMPID Integer,
- O_TASKSTARTDATE Timestamp,
- O_EMPLOYERID Integer,
- O_EMPLOYERNAME Varchar(2000),
- O_ISBOSS Smallint,
- O_PROJID Integer,
- O_PROJECT_NAME Varchar(200),
- O_DIFFTIME Timestamp,
- O_NUMERATOR Varchar(1000),
- O_TSREPORT Timestamp )
- AS
- DECLARE VARIABLE L_DEPID INTEGER;
- DECLARE VARIABLE L_LAST_ACTIONID INTEGER;
- DECLARE VARIABLE L_LAST_ACTIONTIME TIMESTAMP;
- DECLARE VARIABLE L_REPORTDATE TIMESTAMP;
- DECLARE VARIABLE L_LEFTDATE TIMESTAMP;
- DECLARE VARIABLE L_RIGHTDATE TIMESTAMP;
- DECLARE VARIABLE L_RESULT SMALLINT;
- DECLARE VARIABLE L_ROOT_DEP INTEGER;
- DECLARE VARIABLE L_HASCHILDS INTEGER;
- DECLARE VARIABLE L_TASK_DOC_EXEC_ID INTEGER;
- DECLARE VARIABLE L_DOCID INTEGER;
- DECLARE VARIABLE L_DOC_TYPE_ID INTEGER;
- DECLARE VARIABLE L_DOC_STATE SMALLINT;
- DECLARE VARIABLE L_IS_WHITH_REPORT SMALLINT;
- DECLARE VARIABLE L_ISREPORTED SMALLINT;
- begin
- if (:i_id_department is not null) then
- begin
- l_root_dep = :i_id_department;
- end
- else
- select id_department from employer where id=:i_id_employer
- into :l_root_dep;
- if (:i_only_this_dep = 0) then
- begin
- select haschilds from department where id = :l_root_dep
- into :l_haschilds;
- if (:l_haschilds = 0) then
- i_only_this_dep = 1;
- end
- for select g.o_taskid, g.o_projid
- from gettaskexecdocbutoutdate_1(:i_from_date, :i_to_date, :l_root_dep) g
- into :o_taskid, :o_projid
- do
- begin
- execute procedure checkrightsfortask(:i_id_employer, :o_taskid)
- returning_values :l_result;
- if(:l_result = 1) then
- begin
- select t.name, t.startdate, t.enddate, t.la_id, t.iswithreport, t.isreported, t.tsreport, t.numerator
- from task t
- where t.id = :o_taskid
- into :o_task_name, :o_taskstartdate, :o_taskenddate, :l_last_actionid, :l_is_whith_report, :l_isreported, :l_reportdate, :O_NUMERATOR;
- select first 1 a.adate
- from actions a
- where a.id=:l_last_actionid
- into :l_last_actiontime;
- select first 1 gt.id_employer
- from grouptask gt
- where gt.id_task=:o_taskid and gt.is_author=1
- into :o_authorid;
- select first 1 gt.id_employer
- from grouptask gt
- where gt.id_task=:o_taskid and gt.is_respperson=1
- into :o_employerid;
- select name from employer where id = :o_authorid
- into :o_author;
- select p.name from project p
- where p.id = :o_projid
- into :O_PROJECT_NAME;
- select name from employer where id = :o_employerid
- into :o_employername;
- /* if (l_is_whith_report=1) then
- begin
- if (l_isreported=1) then
- begin
- l_leftdate=:l_reportdate;
- l_rightdate=:o_taskenddate;
- O_DIFFTIME = cast((cast(:l_leftdate as timestamp)-cast(:l_rightdate as timestamp))*100 as integer)/100;
- end
- else
- begin
- O_DIFFTIME = cast((cast(:l_last_actiontime as timestamp)-cast(:o_taskenddate as timestamp))*100 as integer)/100;
- end
- end
- else
- begin
- O_DIFFTIME = cast((cast(:l_last_actiontime as timestamp)-cast(:o_taskenddate as timestamp))*100 as integer)/100;
- end
- */
- --O_DIFFTIME = :l_reportdate - :o_taskenddate;
- O_TSREPORT = :l_reportdate;
- suspend;
- end
- end
- if (:i_only_this_dep = 0) then
- begin
- for select id_department
- from deppermission
- where id_employer=:i_id_employer and enabled > 0
- into :l_depid
- do
- begin
- select o_result from is_sub_dep(:l_depid, :l_root_dep) into :l_result;
- if (:l_result = 1) then
- begin
- for select g.o_taskid, g.o_projid
- from gettaskexecdocbutoutdate_1(:i_from_date, :i_to_date, :l_depid) g
- into :o_taskid, :o_projid
- do
- begin
- execute procedure checkrightsfortask(:i_id_employer, :o_taskid)
- returning_values :l_result;
- if(:l_result = 1) then
- begin
- select t.name, t.startdate, t.enddate, t.la_id, t.iswithreport, t.isreported, t.tsreport, t.numerator
- from task t
- where t.id = :o_taskid
- into :o_task_name, :o_taskstartdate, :o_taskenddate, :l_last_actionid, :l_is_whith_report, :l_isreported, :l_reportdate, :O_NUMERATOR;
- select first 1 a.adate
- from actions a
- where a.id=:l_last_actionid
- into :l_last_actiontime;
- select first 1 gt.id_employer
- from grouptask gt
- where gt.id_task=:o_taskid and gt.is_author=1
- into :o_authorid;
- select first 1 gt.id_employer
- from grouptask gt
- where gt.id_task=:o_taskid and gt.is_respperson=1
- into :o_employerid;
- select name from employer where id = :o_authorid
- into :o_author;
- select p.name from project p
- where p.id = :o_projid
- into :O_PROJECT_NAME;
- select name from employer where id = :o_employerid
- into :o_employername;
- --O_DIFFTIME = :l_reportdate - :o_taskenddate;
- O_TSREPORT = :l_reportdate;
- suspend;
- end
- end
- end
- end
- end
- end^
- SET TERM ; ^
- commit;
- /*-----------------------------------------------------------------------------------------------------------------------------------------------*/
- /*-----------------------------------------------------------------------------------------------------------------------------------------------*/
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE GETOUTDATED_1 (
- I_ID_EMPLOYER Integer,
- I_IS_BOSS Smallint,
- I_ID_DEPARTMENT Smallint )
- RETURNS (
- O_TASKID Integer,
- O_EMPLOYERID Integer,
- O_DEPID Integer )
- AS
- DECLARE VARIABLE L_IS_BOSS SMALLINT;
- DECLARE VARIABLE L_ISSECRET SMALLINT;
- begin
- for
- select t.id,t.issecret
- from task t
- where
- t.isdeleted =0 and
- t.id_department = :i_id_department and
- (select o_result from checkrightsfortask (:I_ID_EMPLOYER, t.id)) = 1 and
- t.enddate < 'NOW' and
- t.state = 0
- into :O_TASKID,:l_issecret
- do
- begin
- if (:l_issecret=0 or (:l_issecret=1 and
- exists (select gt.id_task
- from grouptask gt
- where gt.id_task=:o_taskid and
- gt.id_original=:i_id_employer) ) ) then
- begin
- for select gt.id_employer
- from grouptask gt
- where gt.id_task = :O_TASKID and
- (gt.is_respperson=1 or gt.is_worker=1)
- into :O_EMPLOYERID
- do
- begin
- select id_department,isboss from employer
- where id = :O_EMPLOYERID
- into :O_DEPID,:l_is_boss;
- if ((:I_IS_BOSS=1 and :l_is_boss=1) or :I_IS_BOSS=0) then
- suspend;
- end
- end
- end
- end^
- SET TERM ; ^
- commit;
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE GETOUTDATED (
- I_ID_EMPLOYER Integer,
- I_DEPID Integer,
- I_ONLY_BOSS Smallint,
- I_ONLY_THIS_DEP Smallint )
- RETURNS (
- NAME Varchar(2000),
- TASK_NAME Varchar(2000),
- AUTHOR Varchar(2000),
- CURR_ACTION Blob sub_type 1,
- ADATE Timestamp,
- TASKID Integer,
- AUTHORID Integer,
- TASKENDDATE Timestamp,
- STATE Smallint,
- ACT_EMPID Integer,
- TASKSTARTDATE Timestamp,
- EMPLOYERID Integer,
- EMPLOYERNAME Varchar(2000),
- ISBOSS Smallint,
- O_PROJECT_ID Integer,
- O_PROJECT_NAME Varchar(200),
- O_DIFFTIME Integer,
- O_NUMERATOR Varchar(1000) )
- AS
- declare variable L_TASKID integer;
- declare variable L_STARTDATE timestamp;
- declare variable L_DEPID integer;
- declare variable L_AUTHORNAME varchar(2000);
- declare variable L_RESULT smallint;
- begin
- for select
- distinct g1.o_taskid
- from getpermissiontree (:I_ID_EMPLOYER, :I_DEPID) gpt,
- getoutdated_1(:I_ID_EMPLOYER,:i_only_boss,:i_depid) g1
- where gpt.o_id = g1.o_depid
- into :TASKID
- do
- begin
- select NAME,
- TASK_NAME,
- AUTHOR,
- CURR_ACTION,
- ADATE,
- AUTHORID,
- TASKENDDATE,
- STATE,
- ACT_EMPID,
- TASKSTARTDATE,
- EMPLOYERID,
- EMPLOYERNAME,
- ISBOSS,
- O_PROJECT_ID,
- O_PROJECT_NAME,
- O_DIFFTIME,
- O_NUMERATOR
- from getoutdated_3(:TASKID)
- into :NAME,
- :TASK_NAME,
- :AUTHOR,
- :CURR_ACTION,
- :ADATE,
- :AUTHORID,
- :TASKENDDATE,
- :STATE,
- :ACT_EMPID,
- :TASKSTARTDATE,
- :EMPLOYERID,
- :EMPLOYERNAME,
- :ISBOSS,
- :O_PROJECT_ID,
- :O_PROJECT_NAME,
- :O_DIFFTIME,
- :O_NUMERATOR;
- suspend;
- end
- if (:i_only_this_dep = 0) then
- begin
- for select id_department
- from deppermission
- where id_employer=:i_id_employer and enabled > 0
- into :l_depid
- do
- begin
- select o_result from is_sub_dep(:l_depid, :i_depid) into :l_result;
- if (:l_result = 1) then
- begin
- for select
- distinct g1.o_taskid
- from getpermissiontree (:I_ID_EMPLOYER, :L_DEPID) gpt,
- getoutdated_1(:I_ID_EMPLOYER,:i_only_boss,:l_depid) g1
- where gpt.o_id = g1.o_depid
- into :TASKID
- do
- begin
- select NAME,
- TASK_NAME,
- AUTHOR,
- CURR_ACTION,
- ADATE,
- AUTHORID,
- TASKENDDATE,
- STATE,
- ACT_EMPID,
- TASKSTARTDATE,
- EMPLOYERID,
- EMPLOYERNAME,
- ISBOSS,
- O_PROJECT_ID,
- O_PROJECT_NAME,
- O_DIFFTIME,
- O_NUMERATOR
- from getoutdated_3(:TASKID)
- into :NAME,
- :TASK_NAME,
- :AUTHOR,
- :CURR_ACTION,
- :ADATE,
- :AUTHORID,
- :TASKENDDATE,
- :STATE,
- :ACT_EMPID,
- :TASKSTARTDATE,
- :EMPLOYERID,
- :EMPLOYERNAME,
- :ISBOSS,
- :O_PROJECT_ID,
- :O_PROJECT_NAME,
- :O_DIFFTIME,
- :O_NUMERATOR;
- suspend;
- end
- end
- end
- end
- end^
- SET TERM ; ^
- commit;
- /*-----------------------------------------------------------------------------------------------------------------------------------------------*/
- /*-----------------------------------------------------------------------------------------------------------------------------------------------*/
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE REPORT1 (
- I_ID_EMPLOYER Integer,
- I_DEPID Integer,
- STARTDATE Timestamp,
- ENDDATE Timestamp,
- I_ONLY_THIS_DEP Smallint )
- RETURNS (
- NAME Varchar(2000),
- TASK_NAME Varchar(2000),
- CURR_ACTION Blob sub_type 1,
- ADATE Timestamp,
- TASKID Integer,
- ISSTARTED Smallint,
- PROJNAME Varchar(200),
- DEPPATH Varchar(2000),
- TASKENDDATE Timestamp,
- STATE Smallint,
- ISREJECTED Smallint,
- PROJ_ID Integer,
- ACT_EMPID Integer,
- ACT_FIRST Integer,
- TASKSTARTDATE Timestamp,
- ISBOSS Smallint,
- ISTRASHPROJECT Smallint )
- AS
- declare variable L_STARTDATE timestamp;
- declare variable L_DEPID integer;
- declare variable L_AUTHORNAME varchar(2000);
- declare variable L_RESULT Smallint;
- begin
- if (I_DEPID <> 0) then
- for select rf.name,
- rf.TASK_NAME,
- rf.taskstartdate,
- rf.TASKID,
- rf.isstarted,
- rf.ProjName,
- rf.deppath,
- rf.taskenddate,
- rf.STATE,
- rf.isrejected,
- rf.PROJ_ID,
- rf.isboss,
- rf.istrashproject,
- rf.curr_action,
- rf.adate,
- rf.act_empid,
- rf.act_first
- from getpermissiontree (:I_ID_EMPLOYER, :I_DEPID) gpt,
- report1_fast(:i_id_employer,:startdate,:enddate) rf
- where rf.depid = gpt.o_id
- into :name,
- :TASK_NAME,
- :taskstartdate,
- :TASKID,
- :isstarted,
- :ProjName,
- :deppath,
- :taskenddate,
- :STATE,
- :isrejected,
- :PROJ_ID,
- :isboss,
- :istrashproject,
- :curr_action,
- :adate,
- :act_empid,
- :act_first
- do
- suspend;
- else
- for select rf.name,
- rf.TASK_NAME,
- rf.taskstartdate,
- rf.TASKID,
- rf.isstarted,
- rf.ProjName,
- rf.deppath,
- rf.taskenddate,
- rf.STATE,
- rf.isrejected,
- rf.PROJ_ID,
- rf.isboss,
- rf.istrashproject,
- rf.curr_action,
- rf.adate,
- rf.act_empid,
- rf.act_first
- from getpermissiontree_for_employer (:I_ID_EMPLOYER,0) gpt,
- report1_fast(:i_id_employer,:startdate,:enddate) rf
- where rf.depid = gpt.o_id
- into :name,
- :TASK_NAME,
- :taskstartdate,
- :TASKID,
- :isstarted,
- :ProjName,
- :deppath,
- :taskenddate,
- :STATE,
- :isrejected,
- :PROJ_ID,
- :isboss,
- :istrashproject,
- :curr_action,
- :adate,
- :act_empid,
- :act_first
- do
- suspend;
- if (:i_only_this_dep = 0) then
- begin
- for select id_department
- from deppermission
- where id_employer=:i_id_employer and enabled > 0
- into :l_depid
- do
- begin
- select o_result from is_sub_dep(:l_depid, :i_depid) into :l_result;
- if (:l_result = 1) then
- begin
- for select t.name,
- t.id,
- t.startdate,
- t.enddate,
- t.state,
- t.id_project,
- t.isrejected,
- t.isstarted,
- a.name,
- a.isfirst,
- a.adate,
- a.id_employer,
- e.name,
- e.isboss
- from actions a
- join task t on t.la_id = a.id
- left join employer e on a.id_employer=e.id
- where a.adate between :startdate and :enddate and
- t.isdeleted = 0 and
- e.id_department= :l_depid and
- (select o_result from checkrightsfortask(:i_id_employer, t.id)) = 1
- into :task_name,
- :taskid,
- :taskstartdate,
- :taskenddate,
- :state,
- :proj_id,
- :isrejected,
- :isstarted,
- :curr_action,
- :act_first,
- :adate,
- :act_empid,
- :name,
- :isboss
- do
- suspend;
- end
- suspend;
- end
- end
- end^
- SET TERM ; ^
- commit;
- /*-----------------------------------------------------------------------------------------------------------------------------------------------*/
- /*-----------------------------------------------------------------------------------------------------------------------------------------------*/
- /*------------------------------------------------------------------------------------------------------------------------------*/
- /* Добавление столбца EXECTIME в таблицу DOCUMENTTEMPLATE*/
- /*------------------------------------------------------------------------------------------------------------------------------*/
- EXECUTE PROCEDURE ADD_FIELD_IF_DOES_NOT_EXIST('DOCUMENTTEMPLATE', 'EXECTIME', 'TIMESTAMP');
- RESULT
- =======
- 0
- commit;
- /*------------------------------------------------------------------------------------------------------------------------------*/
- /* Процедура для втавки актуального уровня в поле IS_CURRENT в таблице ROUTETREES */
- /*------------------------------------------------------------------------------------------------------------------------------*/
- EXECUTE PROCEDURE ADD_FIELD_IF_DOES_NOT_EXIST_D('ROUTETREES', 'IS_CURRENT', 'INTEGER', '0');
- RESULT
- =======
- 1
- commit;
- SET TERM ^ ;
- CREATE PROCEDURE INSERTROUTEACTUALLEVELS
- AS
- declare variable idtask integer;
- declare variable iscurrent integer;
- declare variable iddocument integer;
- declare variable r_stage integer;
- declare variable current_doc integer;
- declare variable is_exist smallint;
- BEGIN
- select count(is_current) from ROUTETREES where is_current > 0
- into :is_exist;
- if(is_exist = 0) then
- BEGIN
- current_doc=0;
- for select max(stage) as stage, id_document from ROUTETREES
- group by id_document
- into :r_stage, :iddocument
- DO
- BEGIN
- if(current_doc<>:iddocument) then
- BEGIN
- update ROUTETREES set is_current=0 where id_document=:iddocument;
- select first 1 id_task from routetrees rt, task t
- where rt.ID_TASK=t.ID and t.STATE=0 and rt.ID_DOCUMENT=:iddocument and rt.STAGE=:r_stage
- into :idtask;
- update ROUTETREES set is_current=1 where id_task=:idtask and id_document=:iddocument and stage=:r_stage;
- current_doc=iddocument;
- END
- END
- END
- END ^
- SET TERM ; ^
- EXECUTE PROCEDURE INSERTROUTEACTUALLEVELS;
- commit;
- DROP PROCEDURE INSERTROUTEACTUALLEVELS;
- commit;
- /*------------------------------------------------------------------------------------*/
- /*stasy - avto dobavlenie postanovchika v zadachi v raznie roly
- nachalo*/
- /*------------------------------------------------------------------------------------*/
- EXECUTE PROCEDURE ADD_FIELD_IF_DOES_NOT_EXIST('TASK_TEMPLATES', 'REALAUTHOR_AS_AUTHOR', 'SMALLINT');
- RESULT
- =======
- 1
- commit;
- EXECUTE PROCEDURE ADD_FIELD_IF_DOES_NOT_EXIST('TASK_TEMPLATES', 'REALAUTHOR_AS_RESPPERSON', 'SMALLINT');
- RESULT
- =======
- 1
- commit;
- EXECUTE PROCEDURE ADD_FIELD_IF_DOES_NOT_EXIST('TASK_TEMPLATES', 'REALAUTHOR_AS_CONTROLER', 'SMALLINT');
- RESULT
- =======
- 1
- commit;
- EXECUTE PROCEDURE ADD_FIELD_IF_DOES_NOT_EXIST('TASK_TEMPLATES', 'REALAUTHOR_AS_WORKER', 'SMALLINT');
- RESULT
- =======
- 1
- commit;
- /*------------------------------------------------------------------------------------*/
- /*konec*/
- /*------------------------------------------------------------------------------------*/
- /*-----------------------------------------------------------------------------------------------------------------------------------------------*/
- /*stasy & Elena: drop hlam*/
- /*-----------------------------------------------------------------------------------------------------------------------------------------------*/
- delete from menuitems m where m.dmess_tagname = 'L_OPTIONS_DOCPREFS3' and m.item_id = 889;
- commit;
- delete from employer_settings where settings_key='DOCUMENT_PREFS_DEFAULT_SETTINGS';
- commit;
- delete from notification_prefs np where np.task_attribute = 2;
- commit;
- /* Delete search menu items */
- delete from menuitems m where m.item_id in (951, 952, 953, 954, 955, 956) or m.dmess_tagname = 'L_GLOBAL_SEARCH';
- commit;
- /*-----------------------------------------------------------------------------------------------------------------------------------------------*/
- /*stasy - opoveshenie o vipolnenii kt*/
- /*------------------------------------------------------------------------------------*/
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE TMP_KT_READY_NOTIFI
- AS
- declare variable is_exist smallint;
- BEGIN
- select count (np.task_attribute) from notification_prefs np where id_employer=0 and action_type = 20
- INTO :is_exist;
- IF (is_exist > 0) THEN exit;
- INSERT INTO NOTIFICATION_PREFS
- (ACTION_TYPE, TASK_ATTRIBUTE, ID_EMPLOYER, SMS, MAIL, SMS_DISABLE, MAIL_DISABLE, EDITION)
- VALUES (20, 1, 0, 1, 1, 0, 0, NULL);
- INSERT INTO NOTIFICATION_PREFS
- (ACTION_TYPE, TASK_ATTRIBUTE, ID_EMPLOYER, SMS, MAIL, SMS_DISABLE, MAIL_DISABLE, EDITION)
- VALUES (20, 3, 0, 1, 1, 0, 0, NULL);
- INSERT INTO NOTIFICATION_PREFS
- (ACTION_TYPE, TASK_ATTRIBUTE, ID_EMPLOYER, SMS, MAIL, SMS_DISABLE, MAIL_DISABLE, EDITION)
- VALUES (20, 4, 0, 1, 1, 0, 0, NULL);
- INSERT INTO NOTIFICATION_PREFS
- (ACTION_TYPE, TASK_ATTRIBUTE, ID_EMPLOYER, SMS, MAIL, SMS_DISABLE, MAIL_DISABLE, EDITION)
- VALUES (20, 5, 0, 1, 1, 0, 0, NULL);
- INSERT INTO NOTIFICATION_PREFS
- (ACTION_TYPE, TASK_ATTRIBUTE, ID_EMPLOYER, SMS, MAIL, SMS_DISABLE, MAIL_DISABLE, EDITION)
- VALUES (20, 6, 0, 1, 1, 0, 0, NULL);
- INSERT INTO NOTIFICATION_PREFS
- (ACTION_TYPE, TASK_ATTRIBUTE, ID_EMPLOYER, SMS, MAIL, SMS_DISABLE, MAIL_DISABLE, EDITION)
- VALUES (20, 7, 0, 1, 1, 0, 0, NULL);
- INSERT INTO NOTIFICATION_PREFS
- (ACTION_TYPE, TASK_ATTRIBUTE, ID_EMPLOYER, SMS, MAIL, SMS_DISABLE, MAIL_DISABLE, EDITION)
- VALUES (20, 8, 0, 1, 1, 0, 0, NULL);
- END ^
- SET TERM ; ^
- commit;
- EXECUTE PROCEDURE TMP_KT_READY_NOTIFI;
- commit;
- DROP PROCEDURE TMP_KT_READY_NOTIFI;
- commit;
- /*------------------------------------------------------------------------------------*/
- /*stasy - opoveshenie o vipolnenii kt - conec*/
- /*------------------------------------------------------------------------------------*/
- /*stasy - procedura proveraet, javlaetsy li odna zapis' spravochnika potomkom drugoy*/
- /*------------------------------------------------------------------------------------*/
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE IS_PARENT_CHILDE_RECORD (
- i_childe integer,
- i_parent integer)
- returns (
- o_result integer)
- as
- declare variable temp_childe integer;
- declare variable temp_perent integer;
- begin
- for select id_parent from meta_record where id = :i_childe
- into :temp_perent
- do
- begin
- if (:temp_perent = :i_parent) then
- begin
- o_result = 1;
- suspend;
- exit;
- end
- if (:temp_perent is null) then
- begin
- o_result = 0;
- suspend;
- exit;
- end
- select o_result from IS_PARENT_CHILDE_RECORD (:temp_perent, :i_parent)
- into :o_result;
- suspend;
- end
- end ^
- SET TERM ; ^
- commit;
- /*------------------------------------------------------------------------------------*/
- /*conec*/
- /*------------------------------------------------------------------------------------*/
- /*------------------------------------------------------------------------------------*/
- /*stasy - indecsi dl'auskorenija otchetow*/
- /*------------------------------------------------------------------------------------*/
- EXECUTE PROCEDURE ADD_INDEX_IF_DOES_NOT_EXIST('DDOCUMENT_REPORTS_INDEX_1', 'DOCUMENTS', 'ISDELETED,STATE,REGDATE');
- RESULT
- =======
- 0
- commit;
- EXECUTE PROCEDURE ADD_INDEX_IF_DOES_NOT_EXIST('DOC_TASK_REPORTS_INDEX_1', 'GROUPTASK', 'TASK_ID_DOCUMENT, ID_EMPLOYER');
- RESULT
- =======
- 0
- commit;
- /*------------------------------------------------------------------------------------*/
- /*------------------------------------------------------------------------------------*/
- /*stasy - merzkiy trigger*/
- /*------------------------------------------------------------------------------------*/
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE TMP_DROP_MERSKIY_TRIGGER
- AS
- declare variable is_exist smallint;
- BEGIN
- SELECT result FROM IS_TRIGGER_EXISTS('NOTICEVIEW_AU0')
- INTO :is_exist;
- IF (is_exist = 1) THEN
- begin
- EXECUTE STATEMENT
- 'DROP TRIGGER NOTICEVIEW_AU0;';
- end
- END ^
- SET TERM ; ^
- commit;
- EXECUTE PROCEDURE TMP_DROP_MERSKIY_TRIGGER;
- commit;
- DROP PROCEDURE TMP_DROP_MERSKIY_TRIGGER;
- commit;
- /*------------------------------------------------------------------------------------*/
- EXECUTE PROCEDURE ADD_FIELD_IF_DOES_NOT_EXIST('NOTICEVIEW', 'ISDELETED', 'SMALLINT');
- RESULT
- =======
- 1
- commit;
- /*---------------------------------------------------------------------------------*/
- /*stasy - rasshirenniy obshii reestr*/
- /*---------------------------------------------------------------------------------*/
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE GETTREE_ID_ONLI (
- i_id integer)
- returns (
- o_id integer)
- as
- begin
- O_ID = I_ID;
- suspend;
- for SELECT ID
- FROM department d
- WHERE PARENTID = :I_ID and isdeleted = 0
- INTO :O_ID
- do
- begin
- for SELECT o_id
- FROM GETTREE_ID_ONLI (:O_ID)
- INTO :O_ID
- do
- suspend;
- end
- end^
- SET TERM ; ^
- commit;
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE GET_FURIGHT_EMP_BY_DEP (
- i_empid integer,
- i_depid integer,
- i_only_this_dep smallint)
- returns (
- o_id_department integer,
- o_empid integer)
- as
- declare variable l_flag smallint;
- declare variable l_depid integer;
- begin
- if (I_ONLY_THIS_DEP = 1) then
- begin
- for select id, e.id_department from employer e
- join permission p on (p.id_boss = :i_empid and p.enabled = 1 and e.id = p.id_employer)
- where e.id_department = :I_DEPID and
- e.isdeleted = 0
- into :O_EMPID,
- :o_id_department
- do
- suspend;
- end
- else
- for select gt.o_id from GETTREE_ID_ONLI (:I_DEPID) gt
- join deppermission dp on ( dp.id_department = gt.o_id
- and id_employer = :i_empid
- and enabled = 1 )
- INTO :L_DEPID
- do
- begin
- begin
- for select id, e.id_department from employer e
- join permission p on (p.id_boss = :i_empid and p.enabled = 1 and e.id = p.id_employer)
- where e.id_department = :L_DEPID and
- e.isdeleted = 0
- into :O_EMPID,
- :o_id_department
- do
- suspend;
- end
- end
- END^
- SET TERM ; ^
- commit;
- /*--------------------------------------------------------------------------------------------------------*/
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE GETDOCUMENTS_REGISTRY (
- i_id_employer integer,
- i_id_department integer,
- i_id_doctype integer,
- i_only_thisdep smallint,
- i_from_date timestamp,
- i_to_date timestamp)
- returns (
- o_id_document integer,
- o_createdate timestamp,
- o_regdate timestamp,
- o_state smallint,
- o_taskid integer,
- o_doc_version integer,
- o_document_files varchar(30000))
- as
- declare variable l_rootdepid integer;
- declare variable l_department integer;
- begin
- if (i_id_department is null) then
- select id_department from employer where id = :i_id_employer
- into :l_rootdepid;
- else
- l_rootdepid = :i_id_department;
- begin
- for select distinct d.id , (select first 1 g.id_task
- from grouptask g
- where g.task_id_document = d.id
- and g.task_id_document <>0
- and g.task_state = 0), d.id_department
- from documents d
- where d.id_department in (select o_id from GETTREE_ID_ONLI (:l_rootdepid))
- and d.regdate >= :i_from_date
- and d.regdate <= :i_to_date
- and d.id_doctype = :I_ID_DOCTYPE
- and
- (
- (d.id_author in (select p.id_employer
- from permission p
- where p.id_boss = :i_id_employer
- and p.enabled = 1))
- or
- (d.id in (select distinct g.task_id_document
- from grouptask g
- where g.id_employer in
- (select p.id_employer
- from permission p
- where p.id_boss = :i_id_employer
- and p.enabled = 1)
- and g.task_id_document <>0)
- )
- )
- into :o_id_document,
- :o_taskid,
- :l_department
- do
- begin
- if (i_only_thisdep = 0 or l_department = i_id_department)
- then
- begin
- select
- d.createdate,
- d.regdate,
- d.state,
- d.doc_version
- from documents d
- where d.id=:o_id_document
- into
- :o_createdate,
- :o_regdate,
- :o_state,
- :o_doc_version;
- select o_document_files from get_doc_files_list(:o_id_document,0)
- into :o_document_files;
- suspend;
- end
- end
- end
- END^
- SET TERM ; ^
- commit;
- /*-------------------------------------------------------------------------------------------------------------*/
- /*ryazanova -----------dobavlenie v adresnyju knigy polzovatelej(292714)----------------------------------------*/
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE UPDATE_ADRESS_BOOK
- AS
- DECLARE VARIABLE lRecID INTEGER;
- DECLARE VARIABLE lDepID INTEGER;
- DECLARE VARIABLE lEmp_ID_Rec INTEGER;
- BEGIN
- FOR
- select d.id_record, em.id_department, em.id_rec_dict
- from employer em, dictionaryrecordtype d
- where em.id_rec_dict = d.id_record and em.isdeleted = 0 and d.id_system = 0
- and em.parentid is null and em.id_department is not null
- INTO :lRecID, :lDepID, :lEmp_ID_Rec
- DO
- BEGIN
- IF (:lRecID IS NOT NULL) THEN
- BEGIN
- UPDATE dictionaryrecordtype d
- SET d.is_system = 1, d.id_system = :lDepID
- WHERE d.id_record = :lRecID;
- END
- END
- END
- ^
- SET TERM ; ^
- EXECUTE PROCEDURE UPDATE_ADRESS_BOOK;
- DROP PROCEDURE UPDATE_ADRESS_BOOK;
- COMMIT;
- /*-------------------------------------------------------------------------------------------------------------*/
- /*------------------------------------------------------------------------------------*/
- /*pmv: polya adresnoi knigi po ymolchaniy */
- /*------------------------------------------------------------------------------------*/
- SET TERM ^ ;
- CREATE OR ALTER procedure SET_ADDRESS_BOOK
- as
- begin
- IF (NOT EXISTS(SELECT
- SETTINGS_VALUE
- FROM EMPLOYER_SETTINGS where (ID_EMPLOYER is null) and (SETTINGS_KEY='table-contacts-grid-state'))) THEN
- BEGIN
- update EMPLOYER_SETTINGS set SETTINGS_VALUE='[{"dataIndex":"path","header":"","sortable":true,"type":1,"width":200,"id":0},{"dataIndex":"f38","header":"","sortable":true,"type":1,"width":200,"hidden":false,"id":1},{"dataIndex":"f39","header":"","sortable":true,"type":1,"width":200,"hidden":false,"id":2},{"dataIndex":"f40","header":"","sortable":true,"type":1,"width":200,"hidden":false,"id":3},{"dataIndex":"f41","header":"","sortable":true,"type":5,"width":90,"hidden":false,"id":4},{"dataIndex":"f42","header":"","sortable":true,"type":1,"width":200,"hidden":false,"id":5},{"dataIndex":"f43","header":"","sortable":true,"type":12,"width":20,"hidden":false,"id":6},{"dataIndex":"f44","header":"","sortable":true,"type":1,"width":200,"hidden":false,"id":7},{"dataIndex":"f45","header":"","sortable":true,"type":1,"width":200,"hidden":false,"id":8},{"dataIndex":"f46","header":"","sortable":true,"type":1,"width":200,"hidden":false,"id":9},{"dataIndex":"f47","header":"","sortable":true,"type":1,"width":200,"hidden":false,"id":10},{"dataIndex":"f48","header":"","sortable":true,"type":1,"width":200,"hidden":false,"id":11},{"dataIndex":"f49","header":"","sortable":true,"type":10,"width":200,"hidden":false,"id":12},{"dataIndex":"f50","header":"","sortable":true,"type":10,"width":200,"hidden":false,"id":13},{"dataIndex":"f51","header":"","sortable":true,"type":10,"width":200,"hidden":false,"id":14},{"dataIndex":"f52","header":"","sortable":true,"type":11,"width":200,"hidden":false,"id":15},{"dataIndex":"f53","header":"","sortable":true,"type":1,"width":200,"hidden":true,"id":16},{"dataIndex":"f54","header":"","sortable":true,"type":2,"width":200,"hidden":true,"id":17},{"dataIndex":"f122","header":"","sortable":true,"type":3,"width":100,"hidden":true,"id":18},{"dataIndex":"f123","header":"","sortable":true,"type":1,"width":200,"hidden":true,"id":19},{"dataIndex":"f124","header":"","sortable":true,"type":1,"width":200,"hidden":true,"id":20},{"dataIndex":"f125","header":"","sortable":true,"type":1,"width":200,"hidden":true,"id":21},{"dataIndex":"f126","header":"","sortable":true,"type":1,"width":200,"hidden":true,"id":22},{"dataIndex":"f127","header":"","sortable":true,"type":13,"width":200,"hidden":true,"id":23},{"dataIndex":"f128","header":"","sortable":true,"type":5,"width":90,"hidden":true,"id":24},{"dataIndex":"f149","header":"","sortable":true,"type":12,"width":20,"hidden":true,"id":33},{"dataIndex":"f140","header":"","sortable":true,"type":8,"width":200,"hidden":true,"id":30},{"dataIndex":"f131","header":"","sortable":true,"type":11,"width":200,"hidden":true,"id":25},{"dataIndex":"f143","header":"","sortable":true,"type":10,"width":200,"hidden":true,"id":31},{"dataIndex":"f144","header":"","sortable":true,"type":2,"width":200,"hidden":true,"id":32},{"dataIndex":"f134","header":"","sortable":true,"type":4,"width":50,"hidden":true,"id":26},{"dataIndex":"f135","header":"","sortable":true,"type":3,"width":100,"hidden":true,"id":27},{"dataIndex":"f136","header":"","sortable":true,"type":6,"width":20,"hidden":true,"id":28},{"dataIndex":"f137","header":"","sortable":true,"type":9,"width":200,"hidden":true,"id":29},{"dataIndex":"f150","header":"","sortable":true,"type":1,"width":200,"hidden":true,"id":34},{"dataIndex":"f152","header":"","sortable":true,"type":12,"width":20,"hidden":true,"id":35}]' where (SETTINGS_KEY='table-contacts-grid-state') and (SETTINGS_VALUE='[{"dataIndex":"path","header":"","sortable":true,"type":1,"width":200,"id":0},{"dataIndex":"f38","header":"","sortable":true,"type":1,"width":200,"hidden":true,"id":1},{"dataIndex":"f39","header":"","sortable":true,"type":1,"width":200,"hidden":true,"id":2},{"dataIndex":"f40","header":"","sortable":true,"type":1,"width":200,"hidden":true,"id":3},{"dataIndex":"f41","header":"","sortable":true,"type":5,"width":90,"hidden":true,"id":4},{"dataIndex":"f42","header":"","sortable":true,"type":1,"width":200,"hidden":true,"id":5},{"dataIndex":"f43","header":"","sortable":true,"type":12,"width":20,"hidden":true,"id":6},{"dataIndex":"f44","header":"","sortable":true,"type":1,"width":200,"hidden":true,"id":7},{"dataIndex":"f45","header":"","sortable":true,"type":1,"width":200,"hidden":true,"id":8},{"dataIndex":"f46","header":"","sortable":true,"type":1,"width":200,"hidden":true,"id":9},{"dataIndex":"f47","header":"","sortable":true,"type":1,"width":200,"hidden":true,"id":10},{"dataIndex":"f48","header":"","sortable":true,"type":1,"width":200,"hidden":true,"id":11},{"dataIndex":"f49","header":"","sortable":true,"type":10,"width":200,"hidden":true,"id":12},{"dataIndex":"f50","header":"","sortable":true,"type":10,"width":200,"hidden":true,"id":13},{"dataIndex":"f51","header":"","sortable":true,"type":10,"width":200,"hidden":true,"id":14},{"dataIndex":"f52","header":"","sortable":true,"type":11,"width":200,"hidden":true,"id":15},{"dataIndex":"f53","header":"","sortable":true,"type":1,"width":200,"hidden":true,"id":16},{"dataIndex":"f54","header":"","sortable":true,"type":2,"width":200,"hidden":true,"id":17},{"dataIndex":"f122","header":"","sortable":true,"type":3,"width":100,"hidden":true,"id":18},{"dataIndex":"f123","header":"","sortable":true,"type":1,"width":200,"hidden":true,"id":19},{"dataIndex":"f124","header":"","sortable":true,"type":1,"width":200,"hidden":true,"id":20},{"dataIndex":"f125","header":"","sortable":true,"type":1,"width":200,"hidden":true,"id":21},{"dataIndex":"f126","header":"","sortable":true,"type":1,"width":200,"hidden":true,"id":22},{"dataIndex":"f127","header":"","sortable":true,"type":13,"width":200,"hidden":true,"id":23},{"dataIndex":"f128","header":"","sortable":true,"type":5,"width":90,"hidden":true,"id":24},{"dataIndex":"f149","header":"","sortable":true,"type":12,"width":20,"hidden":true,"id":33},{"dataIndex":"f140","header":"","sortable":true,"type":8,"width":200,"hidden":true,"id":30},{"dataIndex":"f131","header":"","sortable":true,"type":11,"width":200,"hidden":true,"id":25},{"dataIndex":"f143","header":"","sortable":true,"type":10,"width":200,"hidden":true,"id":31},{"dataIndex":"f144","header":"","sortable":true,"type":2,"width":200,"hidden":true,"id":32},{"dataIndex":"f134","header":"","sortable":true,"type":4,"width":50,"hidden":true,"id":26},{"dataIndex":"f135","header":"","sortable":true,"type":3,"width":100,"hidden":true,"id":27},{"dataIndex":"f136","header":"","sortable":true,"type":6,"width":20,"hidden":true,"id":28},{"dataIndex":"f137","header":"","sortable":true,"type":9,"width":200,"hidden":true,"id":29},{"dataIndex":"f150","header":"","sortable":true,"type":1,"width":200,"hidden":true,"id":34},{"dataIndex":"f152","header":"","sortable":true,"type":12,"width":20,"hidden":true,"id":35}]');
- INSERT INTO EMPLOYER_SETTINGS(SETTINGS_KEY, SETTINGS_VALUE) values ('table-contacts-grid-state', '[{"dataIndex":"path","header":"","sortable":true,"type":1,"width":200,"id":0},{"dataIndex":"f38","header":"","sortable":true,"type":1,"width":200,"hidden":false,"id":1},{"dataIndex":"f39","header":"","sortable":true,"type":1,"width":200,"hidden":false,"id":2},{"dataIndex":"f40","header":"","sortable":true,"type":1,"width":200,"hidden":false,"id":3},{"dataIndex":"f41","header":"","sortable":true,"type":5,"width":90,"hidden":false,"id":4},{"dataIndex":"f42","header":"","sortable":true,"type":1,"width":200,"hidden":false,"id":5},{"dataIndex":"f43","header":"","sortable":true,"type":12,"width":20,"hidden":false,"id":6},{"dataIndex":"f44","header":"","sortable":true,"type":1,"width":200,"hidden":false,"id":7},{"dataIndex":"f45","header":"","sortable":true,"type":1,"width":200,"hidden":false,"id":8},{"dataIndex":"f46","header":"","sortable":true,"type":1,"width":200,"hidden":false,"id":9},{"dataIndex":"f47","header":"","sortable":true,"type":1,"width":200,"hidden":false,"id":10},{"dataIndex":"f48","header":"","sortable":true,"type":1,"width":200,"hidden":false,"id":11},{"dataIndex":"f49","header":"","sortable":true,"type":10,"width":200,"hidden":false,"id":12},{"dataIndex":"f50","header":"","sortable":true,"type":10,"width":200,"hidden":false,"id":13},{"dataIndex":"f51","header":"","sortable":true,"type":10,"width":200,"hidden":false,"id":14},{"dataIndex":"f52","header":"","sortable":true,"type":11,"width":200,"hidden":false,"id":15},{"dataIndex":"f53","header":"","sortable":true,"type":1,"width":200,"hidden":true,"id":16},{"dataIndex":"f54","header":"","sortable":true,"type":2,"width":200,"hidden":true,"id":17},{"dataIndex":"f122","header":"","sortable":true,"type":3,"width":100,"hidden":true,"id":18},{"dataIndex":"f123","header":"","sortable":true,"type":1,"width":200,"hidden":true,"id":19},{"dataIndex":"f124","header":"","sortable":true,"type":1,"width":200,"hidden":true,"id":20},{"dataIndex":"f125","header":"","sortable":true,"type":1,"width":200,"hidden":true,"id":21},{"dataIndex":"f126","header":"","sortable":true,"type":1,"width":200,"hidden":true,"id":22},{"dataIndex":"f127","header":"","sortable":true,"type":13,"width":200,"hidden":true,"id":23},{"dataIndex":"f128","header":"","sortable":true,"type":5,"width":90,"hidden":true,"id":24},{"dataIndex":"f149","header":"","sortable":true,"type":12,"width":20,"hidden":true,"id":33},{"dataIndex":"f140","header":"","sortable":true,"type":8,"width":200,"hidden":true,"id":30},{"dataIndex":"f131","header":"","sortable":true,"type":11,"width":200,"hidden":true,"id":25},{"dataIndex":"f143","header":"","sortable":true,"type":10,"width":200,"hidden":true,"id":31},{"dataIndex":"f144","header":"","sortable":true,"type":2,"width":200,"hidden":true,"id":32},{"dataIndex":"f134","header":"","sortable":true,"type":4,"width":50,"hidden":true,"id":26},{"dataIndex":"f135","header":"","sortable":true,"type":3,"width":100,"hidden":true,"id":27},{"dataIndex":"f136","header":"","sortable":true,"type":6,"width":20,"hidden":true,"id":28},{"dataIndex":"f137","header":"","sortable":true,"type":9,"width":200,"hidden":true,"id":29},{"dataIndex":"f150","header":"","sortable":true,"type":1,"width":200,"hidden":true,"id":34},{"dataIndex":"f152","header":"","sortable":true,"type":12,"width":20,"hidden":true,"id":35}]');
- END
- suspend;
- end
- ^
- SET TERM ; ^
- commit;
- execute procedure set_address_book;
- commit;
- drop procedure set_address_book;
- commit;
- /*-------------------------------------------------------------------------------------------------------------*/
- /*valer00n: Сортировка папок библиотеки по типам*/
- SET TERM ^ ;
- ALTER PROCEDURE GET_DL_USERTREE (
- I_ID_PARENT Integer,
- I_LEVEL Integer,
- EMPID Integer )
- RETURNS (
- O_ID Integer,
- O_NAME Varchar(200),
- O_LEVEL Integer,
- O_RIGHTS Integer,
- O_OBJ_TYPE Integer )
- AS
- DECLARE VARIABLE L_SUB_RIGHT SMALLINT;
- DECLARE VARIABLE L_NEXT_LEVEL SMALLINT;
- begin
- L_NEXT_LEVEL=:i_level;
- for select df.ID, df.NAME,dp.rights,dp.issubrights, df.OBJ_TYPE
- from DLFOLDER df
- join dlpermissions dp on (dp.id_dlfolder=df.id and dp.id_employer=:EMPID)
- where df.isdeleted =0 and df.parentid=:I_ID_PARENT order by df.OBJ_TYPE,df.name
- into :o_id,:o_name,:O_RIGHTS,:l_sub_right,:o_obj_type
- do
- begin
- L_NEXT_LEVEL=:i_level;
- if (:O_RIGHTS>0) then
- begin
- L_NEXT_LEVEL=:i_level+1;
- o_level=:i_level;
- suspend;
- end
- if (:O_RIGHTS>0 or :l_sub_right>0) then
- begin
- for select gdlt.o_id,gdlt.o_name,gdlt.o_level,gdlt.o_rights, gdlt.o_obj_type
- from get_dl_usertree(:o_id,:l_next_level,:empid) gdlt
- into :o_id,:o_name,:o_level,:o_rights,:o_obj_type
- do
- suspend;
- end
- end
- end^
- SET TERM ; ^
- commit;
- SET TERM ^ ;
- ALTER PROCEDURE GETDLPERMTREE_FOR_EMPLOYER (
- I_ID Integer )
- RETURNS (
- O_ID Integer,
- O_NAME Varchar(2000),
- O_LEVEL Integer,
- RIGHTS Integer,
- O_OBJ_TYPE Integer )
- AS
- DECLARE VARIABLE L_ROOTDEP INTEGER;
- DECLARE VARIABLE L_ROOTDEP_NAME INTEGER;
- DECLARE VARIABLE START_LEVEL INTEGER;
- DECLARE VARIABLE IS_ADMIN INTEGER;
- DECLARE VARIABLE ADMIN_DEP INTEGER;
- begin
- select id
- from dlfolder
- where parentid = 0
- and isdeleted<>1
- into :L_ROOTDEP;
- select O_RESULT from GET_RIGHT_EMPLOYER_AND_GROUP(:I_ID,7,0) into :is_admin;
- /* if (is_admin=1) then
- begin
- SELECT id, name, 0, 0
- from dlfolder
- where parentid = 0
- and isdeleted<>1
- into :O_ID, :O_NAME, :O_LEVEL, :RIGHTS;
- suspend;
- for
- SELECT o_id, o_name, o_level,O_RIGHTS FROM GETDLOLDTREE(:L_ROOTDEP, 1, :I_ID)
- INTO :O_ID, :O_NAME, :O_LEVEL,:RIGHTS
- do
- suspend;
- select d.id from employer e join dlfolder d on d.id_obj=e.id_department
- where e.id=:i_id and d.isdeleted=0 and d.obj_type=1 into :admin_dep;
- SELECT id, name, 1, 0
- from dlfolder d
- where d.id=:admin_dep
- into :O_ID, :O_NAME, :O_LEVEL, :RIGHTS;
- suspend;
- RIGHTS=3;
- for
- SELECT o_id, o_name, o_level FROM GETDLSYSTREE(:admin_dep, 1)
- INTO :O_ID, :O_NAME, :O_LEVEL
- do
- suspend;
- end
- else begin */
- for
- SELECT o_id, o_name, o_level,O_RIGHTS,O_OBJ_TYPE FROM GET_DL_USERTREE(0, 0, :I_ID)
- INTO :O_ID, :O_NAME, :O_LEVEL,:RIGHTS,:O_OBJ_TYPE
- do
- suspend;
- --end
- end^
- SET TERM ; ^
- commit;
- /*------------------------------------------------------------*/
- /*-------------------------------------------------------------------------------------------------------------*/
- /*kos: edited the trigger for tasks and - close and deleted project*/
- /*--------------------------------------------------------------------------------------------------------------*/
- SET TERM ^ ;
- CREATE OR ALTER trigger task_au0 for task
- active before update position 0
- as
- declare variable task_id int;
- declare variable task_count int;
- declare variable l_idroutetree integer;
- declare variable l_idemployer integer;
- declare variable l_idnotice integer;
- declare variable l_id_docexec integer;
- declare variable l_task_valuation_id integer;
- begin
- --закрывается без доклада
- if (new.iswithreport = 0 and old.state = 0 and new.state = 1) then new.tsreport = 'now';
- --задача с докладом
- if (new.iswithreport = 1) then
- begin
- --доклад отправлен, но задача не закрыта
- if (old.isreported=0 and new.isreported=1 and new.state = 0) then
- new.respp_report = 'now';
- --задача закрыта
- if (old.state = 0 and new.state = 1) then
- new.tsreport = 'now';
- --возвращена на доработку
- if (old.isreported=1 and new.isreported=0 and new.state = 0) then
- new.respp_report = null;
- end
- if (new.isdeleted=1 and old.isdeleted =0) then
- begin
- update attachment set isdeleted = 1
- where id_task=new.id;
- end
- if (new.isdeleted=1 and old.isdeleted =0) then
- begin
- update attachment set isdeleted = 1
- where id_task=new.id;
- end
- /* меняем task_state в grouptask */
- update grouptask set task_state=new.state
- where id_task=new.id and (task_state != new.state or task_state is null);
- if (new.state =1 and old.state = 0) then /*закрытие задачи - снимаем с контроля*/
- begin
- delete from hiddentasks where id_task=new.id;
- select count (id) from task
- where id_project =old.id_project
- and state= 0
- into :task_count;
- /*напоминания*/
- for select n.id from notice n where n.id_task = new.id
- into :l_idnotice do
- begin
- execute procedure delete_notice(:l_idnotice);
- end
- end
- if (new.state = 0 and old.state = 1) then /*восстановление задачи + проект*/
- begin
- update project set state=0
- where id=new.id_project and state!=0;
- new.id_valuation=null;/*сбрасываем точку восстановленной*/
- update grouptask gt set gt.is_viewed_task=0 where gt.id_task=new.id;
- update actions a set a.examinated=0 where a.examinated=1 and a.id_task=new.id;
- end
- end
- ^
- SET TERM ; ^
- COMMIT;
- SET TERM ^ ;
- CREATE OR ALTER trigger department_bu0 for department
- active before update position 0
- as
- declare variable newname varchar (200);
- declare variable l_count integer;
- begin
- if (new.isdeleted = 1 and old.isdeleted = 0) then
- begin
- update employer
- set isdeleted =1
- where id_department = new.id;
- end
- if (new.name <> old.name) then
- begin
- newname = new.name || ': {L_GLOBAL_TASK_OUTOFPROJ}';
- update project set name = :newname
- where ID_Department = new.id and istrash = 1;
- end
- end
- ^
- SET TERM ; ^
- COMMIT;
- /*-------------------------------------------------------------------------------------------------------------*/
- EXECUTE PROCEDURE ADD_INDEX_IF_DOES_NOT_EXIST('NOTICE_IDX5', 'NOTICE', 'ISDELETED');
- RESULT
- =======
- 1
- commit;
- EXECUTE PROCEDURE ADD_INDEX_IF_DOES_NOT_EXIST('GROUPTASK_IDX2', 'GROUPTASK', 'ID_ORIGINAL, IS_HIDDEN_TASK, SHOW_TASK_DATE');
- RESULT
- =======
- 1
- commit;
- /*-------------------------------------------------------------------------------------------------------------*/
- /* Alisa Kotova, svetograd.motiw.ru task 6675 - get arcive documents by type and registration date*/
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE GETDOCUMENTS_ARCHIVE_MY (
- I_EMPLOYER_ID Integer,
- I_REGDATE_FROM Timestamp,
- I_REGDATE_TO Timestamp )
- RETURNS (
- O_DOC_TYPE Integer,
- O_DOCID Integer,
- O_IS_RIGHT_ARHIV Integer )
- AS
- declare variable is_emplouer integer; /*есть права на автора*/
- declare variable is_autor integer; /*есть права на участника задач по документу*/
- begin
- /*----------------------------------------------------------------------------------------*/
- for select d.id, (select p.ID_Boss
- from permission p
- where p.ID_Boss = :i_employer_id
- and p.ID_Employer = d.id_author
- and p.enabled = 1
- ), d.id_doctype
- from documents d
- where d.regdate >= :i_regdate_from and d.regdate <= :i_regdate_to
- and d.state = 4 and d.isdeleted = 0
- into :o_docid,
- :is_autor,
- :o_doc_type
- do
- /*----------------------------------------------------------------------------------------*/
- /*если есть права на атора документа, то все, в архив попадает*/
- if (is_autor <> 0) then
- begin
- O_IS_RIGHT_ARHIV = 1;
- suspend;
- end
- /*----------------------------------------------------------------------------------------*/
- /*если нет, проверяем права на участников задач по документу (с ботами блин)*/
- else
- begin
- select count (g.task_id_document)
- from grouptask g
- where g.task_id_document = :o_docid
- and g.id_employer in (select p.id_employer from permission p
- where p.id_boss = :i_employer_id
- and p.enabled = 1)
- into :is_emplouer;
- /*----------------------------------------------------------------------------------------*/
- /*если подходящие задачи есть, то все ок, попадает в отчет*/
- if (is_emplouer <> 0) then
- begin
- O_IS_RIGHT_ARHIV = 1;
- end
- /*----------------------------------------------------------------------------------------*/
- /*если нет, то без вариантов - этого документа в отчете нет*/
- else
- begin
- O_IS_RIGHT_ARHIV = 0;
- end
- suspend;
- end
- end^
- SET TERM ; ^
- commit;
- GRANT EXECUTE
- ON PROCEDURE GETDOCUMENTS_ARCHIVE_MY TO SYSDBA;
- commit;
- /* PM Kratkaya informaciya*/
- EXECUTE PROCEDURE ADDMENUITEMBYTAG(903, 'L_MENU_BRIEF_INFO', '/user/hellopageuser/', 'L_ADDITIONAL', 3, 1, 0, NULL);
- commit;
- /* Unique attribute for doccard field */
- EXECUTE PROCEDURE ADD_FIELD_IF_DOES_NOT_EXIST_D('DOCCARDS', 'ISUNIQUE', 'SMALLINT', '0');
- RESULT
- =======
- 1
- commit;
- /*ryazanova---Ispravit' nazvanija zadach IRG (6780)*/
- update task t
- set t.name = (select t1.name from task t1 where t1.id = t.parentid) || ' (' || t.irg_name || ')'
- where t.is_isolated = 1 and t.irg_name <> '';
- commit;
- /*-------------------------------------------------------------------------------------------------------------------------------*/
- /*ryazanova: derevo podrazdelenij v obratnom porjadke*/
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE get_backward_tree (
- dep_id integer)
- returns (
- o_id integer)
- as
- DECLARE VARIABLE L_K SMALLINT;
- begin
- O_ID = :dep_id;
- suspend;
- for SELECT PARENTID
- FROM department d
- WHERE ID = :dep_id and isdeleted = 0
- INTO :O_ID
- do
- begin
- for SELECT o_id
- FROM get_backward_tree (:O_ID)
- INTO :O_ID
- do
- suspend;
- end
- end
- ^
- SET TERM ; ^
- commit;
- /*-------------------------------------------------------------------------------------------------------------------------------*/
- /* Ryazanova - На ботов полномочия не удалять*/
- SET TERM ^ ;
- CREATE OR ALTER TRIGGER EMPLOYER_AU0 FOR EMPLOYER
- ACTIVE AFTER UPDATE POSITION 0
- as
- declare variable bossid integer;
- declare variable fbossid integer;
- declare variable projid integer;
- declare variable flag integer;
- declare variable l_empid integer;
- declare variable l_isdeleted integer;
- declare variable l_enabled smallint;
- declare variable l_parentid integer;
- begin
- if (new.isdeleted = 1 and old.isdeleted = 0) then
- begin
- /* for select id_boss
- from permission
- where id_employer = new.id and
- enabled >0
- into :l_empid
- do
- begin
- select isdeleted from employer where id = :l_empid
- into :l_isdeleted;
- if (l_isdeleted=0) then
- execute procedure set_permission_dep (l_empid, new.id);
- end */
- update permission
- set enabled=0
- where id_boss=new.id;
- /* update permission
- set enabled=0
- where id_employer=new.id; */
- /* Удаляем из всех пользовательских деревьев */
- delete from ud_employer where id_employer=new.id;
- end
- if (new.isdeleted = 0 and old.isdeleted=1) then
- execute procedure convertpermissions (new.id, new.isboss);
- if (new.id_department != old.id_department) then
- begin
- for select distinct t.id_project
- from grouptask gt
- left join task t on (gt.id_task=t.id)
- where gt.id_employer = old.id and gt.is_respperson=1
- into :projid
- do
- begin
- flag = null;
- select count(id_project) from PROJECT_DEP
- where id_Project = :projid and ID_Department = new.id_department
- into :flag; /*проверяем не привязан ли уже этот проект к новому подразделению*/
- if ((flag is null) or (flag = 0)) then /*если нет, то привязываем*/
- insert into PROJECT_DEP (ID_Project, ID_Department)
- values (:projid,new.id_department);
- flag = null;
- /* old begin */
- /* select count (t.id) --проверяем остались ли еще задачи для этого проекта в старом подразделении
- from task t
- join employer e on t.id_employer = e.id
- where t.id_project =:projid and
- t.ID_employer != old.id and
- e.id_department = old.id_department
- into :flag;
- */ /* old end */
- /* new begin */
- select count (t.id) /*проверяем остались ли еще задачи для этого проекта в старом подразделении*/
- from task t
- join grouptask gt on (t.id = gt.id_task and gt.is_worker = 1)
- join employer e on gt.id_employer = e.id
- where t.id_project =:projid and
- gt.ID_employer != old.id and
- e.id_department = old.id_department
- into :flag;
- /* new end */
- if ((flag is null) or (flag = 0)) then /*если нет, то удаляем привязку этого проекта к подразделению*/
- delete from PROJECT_DEP where
- id_project = :projid and
- id_department = old.id_department;
- end
- update permission
- set enabled = 0
- where id_boss = new.id and
- is_manual=0;
- execute procedure convertpermissions (new.id, new.isboss);
- select parentid from employer where id = new.id
- into :l_parentid;
- /*Обновляем deppermission для боссов данного пользователя*/
- for select id_boss,enabled
- from permission
- where id_employer = new.id and
- enabled <> 0
- into :l_empid,:l_enabled
- do
- begin
- select isdeleted from employer where id = :l_empid
- into :l_isdeleted;
- if (l_isdeleted = 0) then
- begin
- /* Проверяем имеет ли начальник права на отдел в который перевели чела
- * и если нет, то удаляем права начальника на чела
- */
- if (not (exists(select d.enabled
- from deppermission d
- where d.id_employer=:l_empid and
- d.id_department = new.id_department and
- d.enabled = :l_enabled)) and :l_empid <> :l_parentid) then
- delete from permission p
- where p.id_boss = :l_empid and
- p.id_employer = new.id;
- else
- execute procedure set_permission_dep (l_empid, new.id);
- /*Проверяем старое подразделение и удаляем его из deppermission, если там
- больше нет пользователей, на которых босс имеет права*/
- if (not exists(select p.id_boss
- from permission p
- join employer e on e.id = p.id_employer
- where e.id_department = old.id_department and
- p.id_boss = :l_empid and
- enabled = :l_enabled)) then
- begin
- delete from deppermission
- where id_department = old.id_department and
- id_employer = :l_empid and
- enabled = :l_enabled;
- end
- end
- end
- end
- if (old.isboss <> new.isboss) then /*смена статуса сотрудника, переделываем полномочия*/
- execute procedure convertpermissions (new.id, new.isboss);
- if (old.pass <> new.pass and old.needpasswordchange = new.needpasswordchange) then
- update employer
- set needpasswordchange = 0
- where id = new.id;
- if (old.name<>new.name or
- old.isboss<>new.isboss or
- old.login<>new.login or
- old.pass<>new.pass or
- old.isdeleted<>new.isdeleted or
- old.email<>new.email or
- old.cphone<>new.cphone or
- old.workphone<>new.workphone or
- old.birthdate<>new.birthdate or
- old.postaddress<>new.postaddress or
- old.homephone<>new.homephone or
- old.cphone2<>new.cphone2 or
- old.commnt<>new.commnt or
- old.manpost<>new.manpost or
- old.fastlogin<>new.fastlogin or
- old.awayto<>new.awayto
- ) then
- update employer
- set name = new.name,
- isboss = new.isboss,
- login = new.login,
- pass = new.pass,
- isdeleted = new.isdeleted,
- email = new.email,
- cphone = new.cphone,
- workphone = new.workphone,
- birthdate = new.birthdate,
- postaddress = new.postaddress,
- homephone = new.homephone,
- cphone2 = new.cphone2,
- commnt = new.commnt,
- manpost = new.manpost,
- fastlogin = new.fastlogin,
- awayto=new.awayto
- where parentid = new.id and
- isdeleted = 0;
- end^
- SET TERM ; ^
- commit;
- /*-------------------------------------------------------------------------------------------------------------------------------*/
- /* Priznak dostupa */
- EXECUTE PROCEDURE ADD_FIELD_IF_DOES_NOT_EXIST('EMPLOYER', 'ACCESS_TOKEN', 'VARCHAR(32)');
- RESULT
- =======
- 1
- commit;
- /* Srok deystviya priznaka dostupa */
- EXECUTE PROCEDURE ADD_FIELD_IF_DOES_NOT_EXIST('EMPLOYER', 'EXPIRE_DATE', 'TIMESTAMP');
- RESULT
- =======
- 1
- commit;
- /*--------------------------------------------------------------------------------------------------*/
- /*stasy - prava na proekty nachalo*/
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE GETPROJECT (
- i_id_employer integer,
- i_show_doc_projects smallint)
- returns (
- o_id integer,
- o_name varchar(200),
- o_description varchar(2000),
- o_startdate timestamp,
- o_enddate timestamp,
- o_depname varchar(2000))
- as
- begin
- if (i_show_doc_projects = 1) then
- begin
- for select distinct d.name,
- p.id,
- p.name,
- p.description,
- p.startdate,
- p.enddate
- from project p
- join department d on (p.id_department = d.id)
- left join task t on (p.id = t.id_project)
- where
- p.isdeleted =0
- and p.state = 0
- --and p.id_document is null
- and
- (
- p.id_author in (select id_employer from permission where id_boss = :i_id_employer and enabled=1)
- or
- t.id in
- (select distinct g.id_task
- from grouptask g
- join task t on t.id=g.id_task
- where g.id_original in
- (select id_employer from permission where id_boss = :i_id_employer and enabled=1)
- and t.isdeleted=0
- and t.is_checkpoint is null
- and (t.issecret=0 or g.id_task in (select id_task from grouptask where id_original = :i_id_employer)))
- )
- into :O_DEPNAME,
- :O_ID,
- :O_NAME,
- :O_DESCRIPTION,
- :O_STARTDATE,
- :O_ENDDATE
- do
- suspend;
- end
- else
- begin
- for select distinct d.name,
- p.id,
- p.name,
- p.description,
- p.startdate,
- p.enddate
- from project p
- join department d on (p.id_department = d.id)
- left join task t on (p.id = t.id_project)
- where
- p.isdeleted =0
- and p.state = 0
- and p.id_document is null
- and
- (
- p.id_author in (select id_employer from permission where id_boss = :i_id_employer and enabled=1)
- or
- t.id in
- (select distinct g.id_task
- from grouptask g
- join task t on t.id=g.id_task
- where g.id_original in
- (select id_employer from permission where id_boss = :i_id_employer and enabled=1)
- and t.isdeleted=0
- and t.is_checkpoint is null
- and (t.issecret=0 or g.id_task in (select id_task from grouptask where id_original = :i_id_employer)))
- )
- into :O_DEPNAME,
- :O_ID,
- :O_NAME,
- :O_DESCRIPTION,
- :O_STARTDATE,
- :O_ENDDATE
- do
- suspend;
- end
- end^
- Statement failed, SQLCODE = -206
- Dynamic SQL Error
- -SQL error code = -206
- -Column unknown
- -T.IS_CHECKPOINT
- -At line 39, column 20
- At line 5683 in file /tmp/patch_db/script
- SET TERM ; ^
- commit;
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE GETPROJECTARCHIVE (
- i_id_employer integer)
- returns (
- o_id integer,
- o_name varchar(200),
- o_description varchar(2000),
- o_startdate timestamp,
- o_enddate timestamp,
- o_depname varchar(2000))
- as
- begin
- for select distinct p.id,
- p.name,
- p.description,
- p.startdate,
- p.enddate,
- d.name
- from project p
- join department d on (p.id_department = d.id)
- left join task t on (p.id = t.id_project)
- where
- p.isdeleted =0
- and p.state = 1
- and
- (
- p.id_author in (select id_employer from permission where id_boss = :i_id_employer and enabled=1)
- or
- t.id in
- (select distinct g.id_task
- from grouptask g
- join task t on t.id=g.id_task
- where g.id_original in
- (select id_employer from permission where id_boss = :i_id_employer and enabled=1)
- and t.isdeleted=0
- and t.is_checkpoint is null
- and (t.issecret=0 or g.id_task in (select id_task from grouptask where id_original = :i_id_employer)))
- )
- into :O_ID,
- :O_NAME,
- :O_DESCRIPTION,
- :O_STARTDATE,
- :O_ENDDATE,
- :O_DEPNAME
- do
- suspend;
- end^
- Statement failed, SQLCODE = -206
- Dynamic SQL Error
- -SQL error code = -206
- -Column unknown
- -T.IS_CHECKPOINT
- -At line 36, column 20
- At line 5868 in file /tmp/patch_db/script
- SET TERM ; ^
- commit;
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE GETNAVIGATIONTREE_PROJ (
- i_id_employer integer,
- i_is_show_archive_projects smallint)
- returns (
- id integer,
- name varchar(200),
- description varchar(2000),
- state smallint,
- color varchar(16),
- is_mark_by_color smallint)
- as
- declare variable l_mydepid integer;
- BEGIN
- select ID_Department from employer where id=:I_ID_EMPLOYER into :L_MYDEPID;
- for select distinct p.id,
- p.name,
- p.description,
- p.state,
- p.color,
- p.is_mark_by_color
- from project p
- left join task t on (p.id = t.id_project)
- where
- p.isdeleted =0
- and (p.state = 0 or p.state = :i_is_show_archive_projects)
- and
- (
- p.id_author in (select id_employer from permission where id_boss = :i_id_employer and enabled=1)
- or
- t.id in
- (select distinct g.id_task
- from grouptask g
- join task t on t.id=g.id_task
- where g.id_original in
- (select id_employer from permission where id_boss = :i_id_employer and enabled=1)
- and t.isdeleted=0
- and t.is_checkpoint is null
- and (t.issecret=0 or g.id_task in (select id_task from grouptask where id_original = :i_id_employer)))
- )
- INTO :ID,
- :NAME,
- :DESCRIPTION,
- :STATE,
- :color,
- :is_mark_by_color
- DO
- BEGIN
- SUSPEND;
- END
- END^
- Statement failed, SQLCODE = -206
- Dynamic SQL Error
- -SQL error code = -206
- -Column unknown
- -T.IS_CHECKPOINT
- -At line 37, column 20
- At line 5975 in file /tmp/patch_db/script
- SET TERM ; ^
- commit;
- /*stasy - prava na proekty conec*/
- /* Добавление домена если такового еще нет.*/
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE CREATE_DOMAIN_IF_NOT_EXIST (
- domain_name varchar(100),
- sql_param_str varchar(300))
- as
- declare variable is_exist varchar(200);
- BEGIN
- SELECT RDB$FIELD_NAME FROM RDB$FIELDS WHERE UPPER( RDB$FIELD_NAME) = UPPER(:domain_name)
- INTO :is_exist;
- if (is_exist is null) THEN
- BEGIN
- EXECUTE STATEMENT
- 'CREATE DOMAIN ' || UPPER(:domain_name)||' '|| :sql_param_str ;
- END
- END^
- SET TERM ; ^
- commit;
- GRANT EXECUTE ON PROCEDURE CREATE_DOMAIN_IF_NOT_EXIST TO SYSDBA;
- commit;
- /* Создаем новый домен для хранения ЭЦП документов,заменяем тип поля в documents.signature*/
- EXECUTE PROCEDURE CREATE_DOMAIN_IF_NOT_EXIST ('BLOB_4096', 'AS BLOB SUB_TYPE 1 SEGMENT SIZE 4096 CHARACTER SET WIN1251');
- commit;
- update RDB$RELATION_FIELDS set RDB$FIELD_SOURCE = 'BLOB_4096', RDB$COLLATION_ID = 0 where (RDB$FIELD_NAME = 'SIGNATURE') and (RDB$RELATION_NAME = 'DOCUMENTS');
- commit;
- SET TERM ^ ;
- /*меняем строчку в вычислении признака issecretary - не учитывались псевдонимы*/
- create or alter procedure INFORMER2_GETMYTASKS (
- ID_EMPLOYER integer,
- ATASKID integer,
- MINTASKID integer)
- returns (
- TASKID integer,
- TASKNAME varchar(2000),
- ISVIEWED smallint,
- ISGROUP smallint,
- ISNEWMESSAGES smallint,
- AMIAUTHOR smallint,
- PRJID integer,
- ISREPORTED smallint,
- AUTHORID integer,
- EMPID integer,
- ISREJECTED smallint,
- ISWITHREPORT smallint,
- LASTACTID integer,
- TASKDESC varchar(10000),
- STARTDATE timestamp,
- ENDDATE timestamp,
- ACTCOUNT integer,
- ATT varchar(24000),
- TASK_TYPE smallint,
- ORDERTYPE smallint,
- DOCUMENTID integer,
- PRIORITY smallint,
- LASTACTDATE timestamp,
- EMPSID varchar(5000),
- DEPPATH varchar(2000),
- STATE smallint,
- LASTACT varchar(10000),
- LASTACTEMPID integer,
- ISONLYFORVIEW smallint,
- USERID integer,
- MYCOLOR smallint,
- SEND_ACTIONS smallint,
- RECEIVE_MAIL smallint,
- RECEIVE_SMS smallint,
- ACOUNT integer,
- LASTACOUNT integer,
- DOCUMENTNAME varchar(1000),
- DOCUMENTTYPEID integer,
- ISRESOLUTION smallint,
- ID_REALAUTHOR integer,
- ID_TASKINITIATOR integer,
- DOCVERSION integer,
- BTN varchar(200),
- PARENTID integer,
- SHOWDATE timestamp,
- IDFOLDER integer,
- ISSECRETARY smallint,
- ISCONTROL smallint,
- CTRLSID varchar(2000),
- SIGNSID varchar(2000),
- IS_HAVE_ISOLATED smallint,
- SYSACTCOUNT integer,
- MEANSACTCOUNT integer,
- ID_CHECKPOINT integer,
- ID_META_DICTIONARY integer,
- NRECORD_TASKTYPE integer,
- AUTHORSID varchar(2000),
- MAINEMPSID varchar(2000),
- NUMERATOR varchar(100),
- ISSECRET smallint,
- NEWACTCOUNT integer,
- IS_COMMITED smallint,
- CTRLID integer,
- ID_LAST_VIEWED_ACT integer,
- LASTCHANGE timestamp,
- ISUSEPARENTDOCS smallint,
- IS_SHOW_TASK smallint)
- as
- declare variable GT_LASTCHANGE timestamp;
- declare variable TA_LASTCHANGE timestamp;
- declare variable I integer;
- declare variable CNT integer;
- declare variable EXECDOCUMENTID varchar(1000);
- declare variable L_ISHIDDEN integer;
- declare variable SID integer;
- begin
- for select TASKID, TASKNAME, ISGROUP,
- AMIAUTHOR, PRJID, IsReported,
- /* AuthorId, EmpId, */IsRejected, IsWithReport,
- taskdesc, startdate, enddate, task_type,
- documentid, priority, deppath, state, IsOnlyForView, UserId, Send_Actions,
- ExecDocumentId, ID_REALAUTHOR, ID_TASKINITIATOR, PARENTID, is_have_isolated, id_checkpoint
- , id_meta_dictionary, nrecord_tasktype,numerator
- from Informer2_Getmytasks1(:ID_EMPLOYER, :ATASKID)
- into :TASKID, :TASKNAME, :ISGROUP,
- :AMIAUTHOR, :PRJID, :IsReported,
- /* :AuthorId, :EmpId,*/ :IsRejected, :IsWithReport,
- :taskdesc, :startdate, :enddate, :task_type,
- :documentid, :priority, :deppath, :state, :IsOnlyForView, :UserId, :Send_Actions,
- :ExecDocumentId, :ID_REALAUTHOR, :ID_TASKINITIATOR,:PARENTID, :is_have_isolated, :id_checkpoint
- ,:id_meta_dictionary, :nrecord_tasktype,:numerator
- do
- if (TaskId=ATaskId or TaskId>MinTaskId)
- then begin
- if (DocumentId is null and ExecDocumentId is null) then OrderType=0;
- else
- if (DocumentId is not null) then OrderType=1;
- else
- if (ExecDocumentId is not null)
- then begin
- OrderType=2;
- DocumentId=ExecDocumentId;
- end
- ISNEWMESSAGES=0;
- EXECUTE PROCEDURE informer2_gettaskids(ID_EMPLOYER, TASKID, IsOnlyForView) returning_values :EMPSID, :CTRLSID, :SIGNSID,
- :AuthorId, :EmpId , :AUTHORSID , :MAINEMPSID, :CTRLID;
- LastActDate=NULL;
- LastActId=-1;
- LastActId=-1;
- ActCount=0;
- LASTACT='';
- LASTACTEMPID=-1;
- idfolder=0;
- newactcount=0;
- MyColor=NULL;
- cnt=NULL;
- select ta.marker_color, ta.count_actions_view, ta.is_view_new_actions, ta.Id_last_viewed_action
- from task_attributes ta
- where ta.id_employer=:id_employer and
- ta.id_task=:taskid
- into :mycolor, :cnt, :ISNEWMESSAGES, :Id_last_viewed_act;
- select o_result
- from CheckTaskViewed(:ID_EMPLOYER, :taskid)
- into :isviewed;
- select t.la_id, t.action_count, t.sysaction_count, t.meansaction_count, t.issecret, t.isuseparentdocs
- from Task t
- where id= :TaskId
- into :LastActId, :ActCount, :sysactcount, :meansactcount, :issecret, :isuseparentdocs;
- if (isuseparentdocs=1) then
- begin
- SELECT O_DocumentID, O_DocumentName FROM getparentdocs(:TaskID)
- into :Documentid, :Documentname;
- end
- if (ActCount is null) then ActCount=0;
- ACount=ActCount;
- if ((ISNEWMESSAGES=1)or(ISNEWMESSAGES is null)or :ActCount=0)
- then ISNEWMESSAGES=0;
- else ISNEWMESSAGES=1;
- if (LastActId is null) then LastActId=0;
- if (LastActId>0) then
- begin
- select adate, Name, ID_Employer
- from Actions
- where id= :LastActId
- into :LastActDate, :LASTACT, :LASTACTEMPID;
- end
- execute procedure Informer2_TaskAtt(:taskid, -1, -1)
- returning_values :att;
- if (MyColor is null) then MyColor=0;
- select O_RECIVE_SMS, O_RECIVE_MAIL
- from GET_TASK_MAIL_SMS(:TaskId, :id_employer)
- into :receive_sms, :receive_mail;
- if (cnt is null) then lastacount=0;
- else lastacount=cnt;
- newactcount=acount-lastacount;
- isresolution=null;
- btn=null;
- select first 1 rt.isresolution, rt.button_caption from routetrees rt
- where rt.id_task = :taskid and
- rt.isvirtual = 0 and
- rt.isdeleted = 0 and
- (exists(select id from routenode rn
- where rn.id_routetree = rt.id and
- rn.id_employer = :id_employer and
- rn.isdeleted = 0))
- into :isresolution, :btn;
- if (isresolution is null) then isresolution=0;
- DocumentName='';
- DocumentTypeId=NULL;
- DocVersion=NULL;
- select Field1, ID_DocType, Doc_Version
- from Documents
- where id= :DocumentId
- into :DocumentName, :DocumentTypeId, :DocVersion;
- i=1;
- if (OrderType=1) then
- begin
- select O_result from documentcommited (:id_employer, :taskid)
- into :is_commited;
- if (is_commited=1) then
- if (not (exists(select first 1 id_task from grouptask where id_task=:TaskId and
- id_employer=:ID_employer and is_controler=1)))
- then i=0;
- end
- else is_commited=0;
- if (IsOnlyForView is null) then IsOnlyForView=0;
- if (IsOnlyForView=1) then
- begin
- /* SignsId=''; */
- if (exists (select first 1 id
- from Actions
- where id_task=:TaskId and
- examinated=1 and
- (id_employer= :id_employer or id_employer in (select O_EMPLOYERID from
- GETEMPLOYERALIASES(:id_employer)))
- ))
- then i=0;
- else begin
- i=1;
- end
- end
- /*if user needs information by the only one task,
- then return this task in any case*/
- if ((i=0) and (ATASKID<>-1)) then i=1;
- if (i=1) then
- begin
- showdate=NULL;
- select gt.show_task_date
- from grouptask gt
- where gt.id_task=:taskid and gt.id_employer=:id_employer
- into :showdate;
- ISSECRETARY=0;
- if (exists(select * from grouptask gr where gr.id_task=:TaskId
- AND GR.id_original=:id_employer and gr.is_shadow=1)) then
- ISSECRETARY=1;
- --повесит пережитком
- ISCONTROL=0;
- SELECT
- t.lastchange,
- ta.lastchange,
- gt.lastchange
- FROM
- task t
- left join task_attributes ta on (ta.id_task = t.id and ta.id_employer = :id_employer)
- left join grouptask gt on (gt.id_task = t.id and gt.id_employer = :id_employer)
- WHERE
- t.id = :taskid
- INTO
- :lastchange,
- :ta_lastchange,
- :gt_lastchange;
- if (:ta_lastchange > :lastchange) then
- begin
- lastchange = :ta_lastchange;
- end
- if (:gt_lastchange > :lastchange) then
- begin
- lastchange = :gt_lastchange;
- end
- is_show_task = 0;
- if (is_show_task = 0) then
- begin
- if (exists ( select
- first (1) gt.id_task
- from
- grouptask gt
- where
- gt.id_task = :taskid and
- (
- gt.id_original = :id_employer OR
- gt.id_original = (select parentid from employer where id = :id_employer)
- )
- and
- (
- gt.is_author = 1 OR
- gt.is_respperson = 1 OR
- gt.is_worker = 1 OR
- gt.is_controler = 1 OR
- gt.is_shadow = 1
- )
- )
- )
- then
- is_show_task = 1;
- if (is_show_task = 1) then
- if (exists( select
- first (1) gt.id_task
- from
- grouptask gt
- join task t on
- t.id = gt.id_task
- where
- gt.id_task = :taskid and
- t.is_isolated = 1 and
- (
- gt.id_original = :id_employer OR
- gt.id_original = (select parentid from employer where id = :id_employer)
- )
- and
- (
- gt.is_author = 1 OR
- gt.is_respperson = 1 OR
- gt.is_worker = 1 OR
- gt.is_controler = 1 OR
- gt.is_shadow = 1
- )
- and exists
- (
- select
- first (1) id_task
- from
- grouptask
- where
- id_task = (select parentid from task where id = :taskid) and
- (
- id_original = :id_employer OR
- id_original = (select parentid from employer where id = :id_employer)
- )
- and
- (
- is_author = 1 OR
- is_respperson = 1 OR
- is_worker = 1 OR
- is_controler = 1 OR
- is_shadow = 1
- )
- )
- )
- )
- then
- is_show_task = 0;
- end
- suspend;
- end
- end
- end^
- SET TERM ; ^
- commit;INSERT INTO SETTINGS (SETTINGS_KEY,SETTINGS_VALUE) VALUES ('version','1.4.18');
- update patch_info
- set paramvalue = 'OK'
- where paramname = 'PATCH_STATUS';
- update patch_info
- set paramvalue = '1.4.18'
- where paramname = 'CURRENT_VERSION';
- commit work;
- commit;
- commit work;
- Use CONNECT or CREATE DATABASE to specify a database
- CONNECT "/var/Motiw/db/motiw.fdb" USER 'SYSDBA' PASSWORD 'masterkey';
- SET NAMES WIN1251;
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE ADD_GRAYSCALE_DAFAULT_PROFILE
- AS
- DECLARE VARIABLE l_employer_id INTEGER;
- BEGIN
- IF (NOT EXISTS(SELECT
- id
- FROM
- employer_settings
- WHERE
- id_employer is null AND settings_key = 'COLORINDICATION_PROFILE_DEFAULT' AND settings_value LIKE 'Grayscale%')) THEN
- BEGIN
- /* добавляем новый профиль */
- INSERT INTO employer_settings
- (id_employer, settings_key, settings_value, tag)
- VALUES
- (null, 'COLORINDICATION_PROFILE_DEFAULT', 'Grayscale;FFFFFF:60:Только что;E6E6E6:480:Совсем недавно;B6B6B6:2880:Недавно;9A9A9A:7200:Средней давности;6A6A6A:14400:Давно;454545:20160:Довольно давно;000000:74880:Очень давно;FF0000:0:Вообще не было;', 1);
- /* меняем старый */
- UPDATE
- employer_settings
- SET
- settings_value = 'Для пользователей;FF3333:0:Только что;FF9933:5:Совсем недавно;FFFF99:30:Недавно;00CC66:60:Средней давности;6699FF:300:Давно;0033CC:1440:Довольно давно;8000FF:10080:Очень давно;000000:0:Вообще не было;',
- tag = 0
- WHERE
- id_employer is null AND settings_key = 'COLORINDICATION_PROFILE_DEFAULT' AND settings_value LIKE 'Для пользователей%';
- END
- END
- ^
- SET TERM ; ^
- COMMIT;
- EXECUTE PROCEDURE ADD_GRAYSCALE_DAFAULT_PROFILE;
- COMMIT;
- DROP PROCEDURE ADD_GRAYSCALE_DAFAULT_PROFILE;
- COMMIT;
- SET TERM ^ ;
- ALTER PROCEDURE GETTASKINFO4SF (
- idemployer integer,
- idtask integer)
- returns (
- taskid integer,
- tasknumber varchar(200),
- priority integer,
- taskname varchar(2000),
- startdate date,
- enddate date,
- author varchar(10000),
- controller varchar(10000),
- responsible varchar(10000),
- worker varchar(10000),
- projectname varchar(10000),
- tasktype varchar(10000),
- taskstate char(4),
- marker integer)
- as
- declare variable is_author smallint;
- declare variable is_controller smallint;
- declare variable is_responsible smallint;
- declare variable is_worker smallint;
- declare variable emp_name varchar(2000);
- declare variable act_cnt integer;
- declare variable istasknew smallint;
- declare variable isactnew smallint;
- declare variable isreport smallint;
- declare variable isreject smallint;
- declare variable i integer;
- declare variable sql varchar(1000);
- BEGIN
- SQL = '';
- if (idtask<>-1) then
- begin
- SQL = ' and t.ID = ' || :idtask;
- end
- for EXECUTE STATEMENT 'select
- t.ID,
- lower(t.NUMERATOR),
- t.PRIORITY,
- lower(t.NAME),
- t.STARTDATE,
- t.ENDDATE,
- lower(p.NAME),
- lower(md.NAME),
- ta.MARKER_COLOR,
- t.action_count,
- (1 - gt.IS_VIEWED_TASK),
- (1-(case ta.IS_VIEW_NEW_ACTIONS when (ta.IS_VIEW_NEW_ACTIONS) then ta.IS_VIEW_NEW_ACTIONS else 0 end)),
- t.ISREPORTED,
- t.ISREJECTED
- from
- TASK t
- join GROUPTASK gt on
- t.ID = gt.ID_TASK
- join PROJECT p on
- p.id = t.ID_PROJECT
- join META_DICTIONARY md on
- md.ID = t.ID_META_DICTIONARY
- left join TASK_ATTRIBUTES ta on
- ta.ID_TASK = gt.ID_TASK and ta.id_employer=gt.id_original
- where
- gt.id_original = ' || :idemployer || ' and gt.task_state=0' || :SQL
- into
- :TASKID,
- :TASKNUMBER,
- :PRIORITY,
- :TASKNAME,
- :STARTDATE,
- :ENDDATE,
- :PROJECTNAME,
- :TASKTYPE,
- :MARKER,
- :ACT_CNT,
- :istasknew,
- :isactnew,
- :isreport,
- :isreject
- do
- begin
- Author = '';
- Controller = '';
- Responsible = '';
- Worker = '';
- for
- select
- gt.IS_AUTHOR,
- gt.IS_CONTROLER,
- gt.IS_RESPPERSON,
- gt.IS_WORKER,
- e.NAME
- from
- GROUPTASK gt
- join EMPLOYER e on
- e.ID = gt.ID_EMPLOYER
- where
- gt.ID_TASK = :TASKID
- into
- :is_author,
- :is_controller,
- :is_responsible,
- :is_worker,
- :emp_name
- do
- begin
- if (is_author = 1) then
- begin
- if (Author <> '') then Author = Author || ',';
- Author = Author || emp_name;
- end
- if (is_controller = 1) then
- begin
- if (Controller <> '') then Controller = Controller || ',';
- Controller = Controller || emp_name;
- end
- if (is_responsible = 1) then
- begin
- if (Responsible <> '') then Responsible = Responsible || ',';
- Responsible = Responsible || emp_name;
- end
- if (is_worker = 1) then
- begin
- if (Worker <> '') then Worker = Worker || ',';
- Worker = Worker || emp_name;
- end
- end
- if ( ( (ACT_CNT=0)or(ACT_CNT is null) ) ) then isactnew = 0;
- if (isreject is null) then isreject = 0;
- taskstate = istasknew || isactnew || isreport || isreject;
- SUSPEND;
- end
- END
- ^
- SET TERM ; ^
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE CLOSE_TASK_WITH_RESOLUTION (
- i_id_task integer)
- as
- declare variable l_subtask_id integer;
- begin
- update task set state=1 where id=:i_id_task;
- for select t.id
- from task t
- where t.parentid=:i_id_task and t.isdeleted=0 and t.state=0
- into :l_subtask_id
- do
- execute procedure CLOSE_TASK_WITH_RESOLUTION(:l_subtask_id);
- end
- ^
- SET TERM ; ^
- GRANT SELECT,UPDATE ON TASK TO PROCEDURE CLOSE_TASK_WITH_RESOLUTION;
- GRANT EXECUTE ON PROCEDURE CLOSE_TASK_WITH_RESOLUTION TO PROCEDURE CLOSE_TASK_WITH_RESOLUTION;
- GRANT EXECUTE ON PROCEDURE CLOSE_TASK_WITH_RESOLUTION TO SYSDBA;
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE TMP_EDITMENU4IAP
- as
- declare variable v_max_num smallint;
- declare variable v_max_item_id integer;
- declare variable v_id integer;
- declare variable v_url varchar(200) character set win1251;
- declare variable v_isvisible smallint;
- declare variable v_isdefvisible smallint;
- declare variable v_id_employer integer;
- declare variable v_old_num integer;
- declare variable v_count integer;
- begin
- if (not exists (select first (1) id from menuitems where dmess_tagname = 'L_MENU_IAP_TASKS')) then
- begin
- select
- max(number),
- max(item_id)
- from
- menuitems
- into
- :v_max_num,
- :v_max_item_id;
- v_max_num = v_max_num + 1;
- v_max_item_id = v_max_item_id + 1;
- for
- select
- id,
- url,
- isvisible,
- isdefvisible,
- id_employer
- from
- menuitems
- where
- dmess_tagname = 'L_MENU_IAP'
- into
- :v_id,
- :v_url,
- :v_isvisible,
- :v_isdefvisible,
- :v_id_employer
- do
- begin
- select first (1)
- number
- from
- menuitems
- where
- dmess_tagname = 'L_MENU_TABLE_TYPES' and
- id_employer = :v_id_employer
- into
- :v_old_num;
- insert into menuitems (
- item_id,
- idparent,
- dmess_tagname,
- url,
- number,
- isvisible,
- isdefvisible,
- right_kind,
- id_employer
- ) values (
- :v_max_item_id,
- :v_id,
- 'L_MENU_IAP_TASKS',
- :v_url,
- :v_old_num,
- :v_isvisible,
- :v_isdefvisible,
- 0,
- :v_id_employer
- );
- update
- menuitems
- set
- idparent = :v_id,
- right_kind = 0,
- number = :v_max_num,
- url = null
- where
- dmess_tagname = 'L_MENU_TABLE_TYPES' and
- id_employer = :v_id_employer;
- end
- update menuitems set url = null, right_kind = 0 where dmess_tagname = 'L_MENU_IAP';
- end
- end^
- SET TERM ; ^
- GRANT SELECT,INSERT,UPDATE ON MENUITEMS TO PROCEDURE TMP_EDITMENU4IAP;
- GRANT EXECUTE ON PROCEDURE TMP_EDITMENU4IAP TO SYSDBA;
- EXECUTE PROCEDURE TMP_EDITMENU4IAP;
- commit;
- DROP PROCEDURE TMP_EDITMENU4IAP;
- commit;
- EXECUTE PROCEDURE ADD_INDEX_IF_DOES_NOT_EXIST('TASK_IDX_NREC_TASKTYPE', 'TASK', 'NRECORD_TASKTYPE');
- RESULT
- =======
- 0
- commit;
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE TMP_DROP_XLAM
- AS
- declare variable is_exist smallint;
- BEGIN
- SELECT result FROM IS_PROCEDURE_EXISTS('GETDOCUMENTS_ARCHIVE_COUNT')
- INTO :is_exist;
- IF (is_exist = 1) THEN
- begin
- EXECUTE STATEMENT
- 'DROP PROCEDURE GETDOCUMENTS_ARCHIVE_COUNT;';
- end
- SELECT result FROM IS_PROCEDURE_EXISTS('GETDOCUMENTS_FORSEARCH_COUNT')
- INTO :is_exist;
- IF (is_exist = 1) THEN
- begin
- EXECUTE STATEMENT
- 'DROP PROCEDURE GETDOCUMENTS_FORSEARCH_COUNT;';
- end
- SELECT result FROM IS_PROCEDURE_EXISTS('GETDOCUMENTS_FORSEARCH_ALL')
- INTO :is_exist;
- IF (is_exist = 1) THEN
- begin
- EXECUTE STATEMENT
- 'DROP PROCEDURE GETDOCUMENTS_FORSEARCH_ALL;';
- end
- SELECT result FROM IS_FIELD_EXISTS('EMPLOYER', 'ISSHOWTOTALPAGES')
- INTO :is_exist;
- IF (is_exist = 1) THEN
- begin
- EXECUTE STATEMENT
- 'ALTER TABLE EMPLOYER DROP ISSHOWTOTALPAGES;';
- end
- END ^
- SET TERM ; ^
- commit;
- EXECUTE PROCEDURE TMP_DROP_XLAM;
- commit;
- DROP PROCEDURE TMP_DROP_XLAM;
- commit;
- /*----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
- /* 05.07.2010 Elena, Поиск документов
- Вот условия, по которым определяется доступ к документам для всех участников:
- 1. Автору документа.
- 2. Пользователю, имеющему полномочия «Полные права» на автора документа.
- 3. Контролеру типа документа, имеющему полномочия «Только свои задачи» или «Полные права» на автора документа.
- 4. Любому участнику задачи по рассмотрению/исполнению документа.
- 5. Контролеру типа документа, имеющему полномочия «Только свои задачи» или «Полные права» на участника задачи по рассмотрению или исполнению документа.
- /*-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE GETDOCUMENTS_FORSEARCH_FAST (
- i_id_employer integer,
- i_id_doctype integer,
- i_doc_version integer)
- returns (
- o_id_document integer)
- as
- declare variable l_isController smallint;
- begin
- select cdtr.o_result
- from CHECKDOCTYPERIGHT(:i_id_doctype, :i_id_employer, 1) cdtr
- into :l_isController;
- if (l_isController = 0) then
- begin
- /* 1. Автору документа.
- 2. Пользователю, имеющему полномочия «Полные права» на автора документа. */
- for select distinct d.id
- from documents d
- inner join GETPERM_ALL(:i_id_employer) gp on (gp.o_id = d.id_author and gp.o_right = 1)
- where d.id_doctype = :i_id_doctype and
- d.doc_version = :i_doc_version and
- d.isdeleted = 0
- into :o_id_document
- do
- suspend;
- /* 4. Любому участнику задачи по рассмотрению/исполнению документа. */
- for select distinct d.id
- from documents d
- left join task t on (t.id_document_exec = d.id or t.id_document = d.id)
- left join grouptask gt on (gt.id_task = t.id)
- where d.isdeleted = 0 and
- d.id_doctype = :i_id_doctype and
- d.doc_version = :i_doc_version and
- gt.id_employer = :i_id_employer
- into :o_id_document
- do
- suspend;
- end
- else
- begin
- /* 1. Автору документа.
- 2. Пользователю, имеющему полномочия «Полные права» на автора документа.
- 3. Контролеру типа документа, имеющему полномочия «Только свои задачи» или «Полные права» на автора документа. */
- for select distinct d.id
- from documents d
- inner join GETPERM_ALL(:i_id_employer) gp on (gp.o_id = d.id_author)
- where d.id_doctype = :i_id_doctype and
- d.doc_version = :i_doc_version and
- d.isdeleted = 0
- into :o_id_document
- do
- suspend;
- /* 4. Любому участнику задачи по рассмотрению/исполнению документа.
- 5. Контролеру типа документа, имеющему полномочия «Только свои задачи» или «Полные права» на участника задачи по рассмотрению или исполнению документа. */
- for select distinct d.id
- from documents d
- left join task t on (t.id_document_exec = d.id or t.id_document = d.id)
- left join grouptask gt on (gt.id_task = t.id)
- inner join GETPERM_ALL(:i_id_employer) gp on (gp.o_id = gt.id_employer)
- where d.isdeleted = 0 and
- d.id_doctype = :i_id_doctype and
- d.doc_version = :i_doc_version
- into :o_id_document
- do
- suspend;
- end
- end^
- SET TERM ; ^
- commit;
- /* добавляем признак "Секретная задача" в шаблоны задач */
- EXECUTE PROCEDURE ADD_FIELD_IF_DOES_NOT_EXIST('TASK_TEMPLATES', 'ISSECRET', 'SMALLINT');
- RESULT
- =======
- 0
- commit;
- SET TERM ^ ;
- ALTER PROCEDURE SIGNDOCUMENT_PASSING_POINT (
- i_routetreeid integer)
- returns (
- o_routetreeid integer,
- o_inarchive integer)
- as
- declare variable l_parentid integer;
- declare variable l_is_do_it smallint;
- declare variable l_x integer;
- declare variable l_y integer;
- declare variable l_taskid integer;
- declare variable l_isvirtual smallint;
- declare variable l_documentid integer;
- declare variable l_stage smallint;
- declare variable k smallint;
- declare variable is_virt smallint;
- declare variable idc integer;
- declare variable idc1 integer;
- declare variable x integer;
- declare variable y integer;
- declare variable l_h integer;
- declare variable is_exit smallint;
- begin
- O_ROUTETREEID = null;
- O_INARCHIVE = 0;
- select
- id_parent, is_do_it, x, y, id_task,
- isvirtual, id_document, stage
- from
- routetrees
- where
- id = :i_routetreeid
- into
- :l_parentid, :l_is_do_it, :l_x, :l_y, :l_taskid,
- :l_isvirtual, :l_documentid, :l_stage;
- /* Устанавливаем is_do_it в 1 у всех совпадающих X Y */
- update routetrees
- set is_do_it = 1
- where
- X = :l_x and
- Y = :l_y and
- ID_DOCUMENT = :l_documentid and
- stage = :l_stage and
- isdeleted = 0;
- /* Проверяем все ли отделы согласовали */
- if (not exists( select
- id
- from
- RouteTrees
- where
- ( IsVirtual = 0 or
- IsVirtual = 2 or
- IsVirtual = 4 or
- IsVirtual = 5 or
- IsVirtual = 6 or
- IsVirtual = 8 or
- IsVirtual = 9 or
- IsVirtual = 10 or
- IsVirtual = 11
- ) and
- ID_Document = :l_documentid and
- IS_DO_IT = 0 and
- stage = :l_stage and
- IsDeleted = 0 and
- ( is_exclude is null or
- is_exclude=0
- )
- )
- )
- then begin
- if (exists( select id
- from routetrees
- where
- ID_Document = :l_documentid and
- stage = :l_stage and
- IsVirtual = 7 and
- isdeleted = 0 and
- ( is_exclude is null or
- is_exclude = 0
- )
- )
- )
- then
- begin
- k = 4;
- O_INARCHIVE = 1;
- end
- else
- k = 1;
- update Documents
- set State = :k
- where ID = :l_documentid;
- update Task
- set State = 1
- where ID = :l_taskid;
- delete from favdocument
- where id_document = :l_documentid;
- suspend;
- exit;
- end
- if (l_isvirtual = 1) then
- begin
- is_exit = 0;
- for
- select O_RESULT, O_ROUTETREEID
- from sign_where_isvirtual_1(:i_routetreeid, :L_DOCUMENTID, :L_STAGE)
- into :L_H, :O_ROUTETREEID
- do
- if (L_H = 1) then
- begin
- is_exit = 1;
- suspend;
- end
- if (is_exit = 1) then exit;
- end
- /* Цикл по всем предкам Если у них есть задачи и он закрытые,
- * то эту тоже закрываем */
- execute procedure signdocument_is_all_parent_sign(:i_routetreeid, 1)
- returning_values :L_H;
- if (L_H = 1) then
- begin
- /* Закрываем задачу */
- update Task
- set State = 1
- where ID = :L_TASKID;
- /* Цикл по всем потомкам */
- k = 0;
- for
- select
- id, x, y, isvirtual
- from
- RouteTrees
- where
- ID_Parent = :i_routetreeid and
- ID_Document = :l_documentid and
- stage = :l_stage and
- IsDeleted = 0 and
- :K = 0
- into
- :IDC, :X, :Y, :IS_VIRT
- do
- begin
- execute procedure signdocument_is_all_parent_sign(:IDC ,0)
- returning_values :L_H;
- if (L_H = 0) then exit;
- end
- if (IS_VIRT = 1) then
- begin
- for
- select
- x, y
- from
- RouteTrees
- where
- ID_Parent = :i_routetreeid and
- ID_Document = :l_documentid and
- stage = :l_stage and
- isvirtual = 1 and
- IsDeleted = 0
- into
- :X, :Y
- do
- begin
- for
- select
- id
- from
- routetrees
- where
- ID_Document = :l_documentid and
- stage = :l_stage and
- isdeleted = 0 and
- x = :X and
- y = :Y
- into
- :IDC
- do
- if (exists( select
- id
- from
- routetrees
- where
- ID_Document = :l_documentid and
- stage = :l_stage and
- isdeleted = 0 and
- id_parent = :IDC
- )
- )
- then
- begin
- for
- select o_routetreeid
- from signdocument_passing_point(:IDC)
- into :o_routetreeid
- do
- suspend;
- end
- end
- exit;
- end
- for
- select
- id, x, y
- from
- RouteTrees
- where
- ID_Parent = :i_routetreeid and
- ID_Document = :l_documentid and
- stage = :l_stage and
- IsDeleted = 0
- into
- :IDC, :X, :Y
- do
- begin
- IDC1 = null;
- select
- min(rt.id_parent)
- from
- routetrees rt,
- routenode rn
- where
- ID_Document = :l_documentid and
- rt.stage = :l_stage and
- rt.isdeleted = 0 and
- rt.x = :X and
- rt.y = :Y and
- ( rn.id_routetree = rt.id or
- rt.isvirtual = 1
- )
- into
- :IDC1;
- if (IDC1 is not null) then
- begin
- O_ROUTETREEID = IDC1;
- suspend;
- exit;
- end
- end
- end
- if ( exists(select first 1 rt.id
- from routetrees rt
- join routenode rn on (rt.id = rn.id_routetree)
- where (rt.isdeleted = 0) and (rn.isdeleted = 0) and (rt.id_task = :l_taskid)
- and (rn.is_do_it = 0) and (rn.necessary = 1) and (rt.id_parent = :l_parentid)))
- then exit;
- O_ROUTETREEID = :i_routetreeid;
- suspend;
- end
- ^
- SET TERM ; ^
- commit;
- EXECUTE PROCEDURE ADD_FIELD_IF_DOES_NOT_EXIST('MENUITEMS', 'EDITION', 'VARCHAR(10)');
- RESULT
- =======
- 0
- commit;
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE ADDNEWMENUITEM (
- i_item_id integer,
- i_dmess_tagname varchar(200),
- i_url varchar(1000),
- i_parent_number integer,
- i_number smallint,
- i_isdefvisible smallint,
- i_right_kind smallint,
- i_edition varchar(10))
- as
- declare variable l_id_employer integer;
- declare variable l_idparent integer;
- begin
- /*Описание: Рта процедура добавляет новые пункты РІ меню.
- Параметры:
- i_item_id - номер, ассоциированный с пунктом меню (для групповых элементов равен null)
- i_dmesstagname - тэг из dmessages.xml, которым называется данный пункт меню
- i_url - ссылка (для групповых элементов не нужна)
- i_parent_number - порядковый номер родительского элемента (или 0, если родителя нет)
- i_number - порядковый номер элемента
- i_isdefvisible - виден ли добавляемый элемент по умолчанию у новых пользователей (0 или 1)
- i_right_kind - кто может видеть данный пункт (см. описание поля right_kind в таблице menuitems)
- i_edition - версия (workflow/docflow) null - видим для всех версий лицензий
- Например:
- 1. Добавить новый 3-й по счету пункт во вторую группу меню:
- execute procedure addnewmenuitem(676,'L_GLOBAL_PROJECT','/user/mytasks/',2,3,1,0,'workflow');
- 2. Добавить новую группу меню:
- execute procedure addnewmenuitem(null,'L_GLOBAL_PROJECT',null,0,3,1,0,null);
- */
- /*добавляем пункт меню в админскую настройку*/
- l_idparent = null;
- if (i_parent_number = 0) then
- l_idparent = 0;
- else
- select id from menuitems m where m.idparent=0 and m.id_employer=0 and m.number=:i_parent_number
- into :l_idparent;
- /*Если был указан неправильный i_parent_number, то ничего не добавляем*/
- if (l_idparent is null) then
- exit;
- /* Проверяем, существует ли уже пункт меню с таким же i_item_id. Если существует, то ничего не делаем. */
- if (exists(select id
- from menuitems
- where item_id=:i_item_id)) then exit;
- if (exists(select id
- from menuitems
- where dmess_tagname=:i_dmess_tagname and url is null)) then exit;
- update menuitems m
- set m.number = m.number + 1
- where m.id_employer=0 and m.idparent=:l_idparent and m.number>=:i_number;
- /*для id_employer = -1 неверно значение :l_idparent. Нужен дополнительный запрос*/
- insert into menuitems (item_id,dmess_tagname,url,idparent,number,
- isdefvisible,right_kind,id_employer,edition)
- values (:i_item_id, :i_dmess_tagname, :i_url, :l_idparent, :i_number,
- :i_isdefvisible, :i_right_kind, -1, :i_edition);
- insert into menuitems (item_id,dmess_tagname,url,idparent,number,
- isdefvisible,right_kind,id_employer,edition)
- values (:i_item_id, :i_dmess_tagname, :i_url, :l_idparent, :i_number,
- :i_isdefvisible, :i_right_kind, 0, :i_edition);
- /*добавляем пункт меню в настройки пользователей*/
- for select e.id from employer e
- where e.isdeleted=0 and e.parentid is null and
- (exists (select first 1 m.id from menuitems m where m.id_employer=e.id))
- into :l_id_employer
- do
- begin
- if (i_parent_number = 0) then
- l_idparent = 0;
- else
- select id from menuitems m
- where m.idparent=0 and m.id_employer=:l_id_employer and m.number=:i_parent_number
- into :l_idparent;
- update menuitems m
- set m.number = m.number + 1
- where m.id_employer=:l_id_employer and m.idparent=:l_idparent and m.number>=:i_number;
- insert into menuitems (item_id,dmess_tagname,url,idparent,number,
- right_kind,id_employer,edition)
- values (:i_item_id, :i_dmess_tagname, :i_url, :l_idparent, :i_number,
- :i_right_kind, :l_id_employer, :i_edition);
- end
- end^
- SET TERM ; ^
- COMMENT ON PROCEDURE ADDNEWMENUITEM IS
- 'Описание: Рта процедура добавляет новые пункты РІ меню.
- Параметры:
- i_item_id - номер, ассоциированный с пунктом меню (для групповых элементов равен null)
- i_dmesstagname - тэг из dmessages.xml, которым называется данный пункт меню
- i_url - ссылка (для групповых элементов не нужна)
- i_parent_number - порядковый номер родительского элемента (или 0, если родителя нет)
- i_number - порядковый номер элемента
- i_isdefvisible - виден ли добавляемый элемент по умолчанию у новых пользователей (0 или 1)
- i_right_kind - кто может видеть данный пункт (см. описание поля right_kind в таблице menuitems)
- i_edition - версия (workflow/docflow) null - видим для всех версий лицензий
- Например:
- 1. Добавить новый 3-й по счету пункт во вторую группу меню:
- execute procedure addnewmenuitem(676,''L_GLOBAL_PROJECT'',''/user/mytasks/'',2,3,1,0,''workflow'');
- 2. Добавить новую группу меню:
- execute procedure addnewmenuitem(null,''L_GLOBAL_PROJECT'',null,0,3,1,0,null);';
- commit;
- /* Добавлено копирование признака "Версия" */
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE COPYMENUITEMS (
- i_id_employer integer)
- as
- declare variable l_id integer;
- declare variable l_item_id integer;
- declare variable l_dmess_tagname varchar(200);
- declare variable l_url varchar(1000);
- declare variable l_number smallint;
- declare variable l_isvisible smallint;
- declare variable l_right_kind smallint;
- declare variable l_edition varchar(10);
- declare variable l_id2 integer;
- declare variable l_item_id2 integer;
- declare variable l_dmess_tagname2 varchar(200);
- declare variable l_url2 varchar(1000);
- declare variable l_number2 smallint;
- declare variable l_isvisible2 smallint;
- declare variable l_isdefvisible2 smallint;
- declare variable l_right_kind2 smallint;
- declare variable l_edition2 varchar(10);
- declare variable l_id_new integer;
- begin
- for select
- m.id, m.item_id, m.dmess_tagname, m.url, m.number,
- m.isvisible, m.right_kind, m.edition
- from menuitems m
- where m.id_employer=0 and m.idparent=0
- into :l_id,:l_item_id,:l_dmess_tagname,:l_url,:l_number,
- :l_isvisible,:l_right_kind,:l_edition
- do
- begin
- l_id_new = gen_id(gen_menuitems_id,1);
- insert into menuitems (id,item_id,dmess_tagname,url,number,isvisible,right_kind,id_employer,edition)
- values (:l_id_new,:l_item_id,:l_dmess_tagname,:l_url,:l_number,:l_isvisible,:l_right_kind,:i_id_employer,:l_edition);
- for select
- m.id, m.item_id, m.dmess_tagname, m.url, m.number,
- m.isvisible, m.isdefvisible, m.right_kind, m.edition
- from menuitems m
- where m.id_employer=0 and m.idparent=:l_id
- into :l_id2,:l_item_id2,:l_dmess_tagname2,:l_url2,:l_number2,
- :l_isvisible2,:l_isdefvisible2,:l_right_kind2,:l_edition2
- do
- begin
- insert into menuitems (item_id,dmess_tagname,url,number,isvisible,right_kind,idparent,id_employer,edition)
- values (:l_item_id2,:l_dmess_tagname2,:l_url2,:l_number2,:l_isvisible2,:l_right_kind2,:l_id_new,:i_id_employer,:l_edition2);
- end
- end
- end^
- SET TERM ; ^
- commit;
- /*Заполняем поле "Версия" для пунктов меню */
- /*
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE TMP_FILL_MENUITEMS_EDITION
- AS
- BEGIN
- UPDATE
- menuitems
- SET
- edition = 'docflow'
- WHERE
- dmess_tagname = 'L_MENU_DOCUMENTS' OR
- dmess_tagname = 'L_DOCPROCESSING' OR
- item_id IN (21, 22, 23, 24, 26, 29, 30, 33, 61, 86, 89, 118, 119, 121, 122, 140, 149, 666, 11100, 11836, 13666);
- UPDATE
- menuitems
- SET
- edition = 'workflow'
- WHERE
- item_id IN (66, 129, 11838);
- END ^
- SET TERM ; ^
- commit;
- EXECUTE PROCEDURE TMP_FILL_MENUITEMS_EDITION;
- commit;
- DROP PROCEDURE TMP_FILL_MENUITEMS_EDITION;
- commit;
- */
- /* добавляем атрибут "Версия" для прав */
- EXECUTE PROCEDURE ADD_FIELD_IF_DOES_NOT_EXIST('GROUPRIGHTS_LIST', 'EDITION', 'VARCHAR(10)');
- RESULT
- =======
- 0
- commit;
- /*Заполняем поле "Версия" для прав */
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE TMP_FILL_RIGHTS_EDITION
- AS
- BEGIN
- UPDATE
- grouprights_list
- SET
- edition = 'docflow'
- WHERE
- id in (4, 11, 31, 32, 33);
- END ^
- SET TERM ; ^
- commit;
- EXECUTE PROCEDURE TMP_FILL_RIGHTS_EDITION;
- commit;
- DROP PROCEDURE TMP_FILL_RIGHTS_EDITION;
- commit;
- /* Выбор прав для workflow-версии (не возвращает права, используемые в документообороте) */
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE GET_RIGHTS_OF_GROUP_WORKFLOW (
- i_id_employer integer,
- i_id_groupright integer)
- returns (
- o_right_kind integer,
- o_id_object integer,
- o_objectname varchar(1000),
- o_group_has_right smallint,
- o_can_edit smallint)
- as
- declare variable l_id_owner integer;
- declare variable l_id_groupright integer;
- begin
- O_ID_OBJECT = 0;
- O_OBJECTNAME = '';
- for select gl.id
- from grouprights_list gl
- where gl.edition = 'workflow' or gl.edition is null
- into :O_RIGHT_KIND
- do
- begin
- select o_result from get_right_employer_and_group(:i_id_employer,:o_right_kind,0)
- into :o_can_edit;
- select o_result from get_right_groupright(:i_id_groupright,:o_right_kind,:o_id_object)
- into :o_group_has_right;
- suspend;
- end
- o_right_kind = 12;
- for select it.id, it.name, it.id_owner from iwgtemplate it
- where it.isdeleted=0
- into :o_id_object, :o_objectname, :l_id_owner
- do
- begin
- if (l_id_owner=i_id_employer or l_id_owner is null ) then
- o_can_edit = 1;
- else
- o_can_edit = 0;
- select o_result from get_right_groupright(:i_id_groupright,:o_right_kind,:o_id_object)
- into :o_group_has_right;
- suspend;
- end
- o_right_kind = 10;
- if (I_ID_GROUPRIGHT is null) then L_ID_GROUPRIGHT=0;
- else
- L_ID_GROUPRIGHT=:I_ID_GROUPRIGHT;
- for select g.id, g.name, g.id_owner from grouprights g
- where g.isdeleted=0 and g.isvisible=1 and g.id<>:L_ID_GROUPRIGHT
- into :o_id_object, :o_objectname, :l_id_owner
- do
- begin
- if (l_id_owner=i_id_employer ) then
- o_can_edit = 1;
- else
- o_can_edit = 0;
- select o_result from get_right_groupright(:i_id_groupright,:o_right_kind,:o_id_object)
- into :o_group_has_right;
- suspend;
- end
- o_right_kind = 15;
- o_can_edit = 1;
- for select md.id, md.name, md.id_owner
- from meta_dictionary md
- where md.isdeleted=0 and md.id_owner=:i_id_employer and recordtype=1
- into :o_id_object, :o_objectname, :l_id_owner
- do
- begin
- select o_result from get_right_groupright(:i_id_groupright,:o_right_kind,:o_id_object)
- into :o_group_has_right;
- suspend;
- end
- /* 17 права на просмотр записей в справочнике */
- /* 18 права на добавление записей в справочник */
- /* 19 права на изменение записей в справочнике */
- /* 20 права на удаление записей в справочнике */
- o_can_edit = 1;
- for select md.id, md.name, md.id_owner
- from meta_dictionary md
- where md.isdeleted=0 and md.id_owner=:i_id_employer and recordtype=0
- into :o_id_object, :o_objectname, :l_id_owner
- do
- begin
- o_right_kind = 17;
- select o_result from get_right_groupright(:i_id_groupright,:o_right_kind,:o_id_object)
- into :o_group_has_right;
- suspend;
- o_right_kind = 18;
- select o_result from get_right_groupright(:i_id_groupright,:o_right_kind,:o_id_object)
- into :o_group_has_right;
- suspend;
- o_right_kind = 19;
- select o_result from get_right_groupright(:i_id_groupright,:o_right_kind,:o_id_object)
- into :o_group_has_right;
- suspend;
- o_right_kind = 20;
- select o_result from get_right_groupright(:i_id_groupright,:o_right_kind,:o_id_object)
- into :o_group_has_right;
- suspend;
- end
- o_right_kind = 22;
- for select tt.id, tt.name, tt.id_owner from task_templates tt
- into :o_id_object, :o_objectname, :l_id_owner
- do
- begin
- if (l_id_owner=i_id_employer or l_id_owner is null ) then
- o_can_edit = 1;
- else
- o_can_edit = 0;
- select o_result from get_right_groupright(:i_id_groupright,:o_right_kind,:o_id_object)
- into :o_group_has_right;
- suspend;
- end
- -- плагины не привязвнные к типам
- o_right_kind = 77;
- for select plg.id, plg.name, plg.id_owner from plugins plg where plg.no_connect_to_type=1
- into :o_id_object, :o_objectname, :l_id_owner
- do
- begin
- if (l_id_owner=i_id_employer or l_id_owner is null ) then
- o_can_edit = 1;
- else
- o_can_edit = 0;
- select o_result from get_right_groupright(:i_id_groupright,:o_right_kind,:o_id_object)
- into :o_group_has_right;
- suspend;
- end
- /* 23 права на просмотр событий календаря */
- /* 24 права на добавление и редактирование событий в календарь */
- /* 25 полные права*/
- o_can_edit = 1;
- for select c.id, c.name, c.id_owner
- from calendars c
- where c.id_owner=:i_id_employer and is_system=0
- into :o_id_object, :o_objectname, :l_id_owner
- do
- begin
- o_right_kind = 23;
- select o_result from get_right_groupright(:i_id_groupright,:o_right_kind,:o_id_object)
- into :o_group_has_right;
- suspend;
- o_right_kind = 24;
- select o_result from get_right_groupright(:i_id_groupright,:o_right_kind,:o_id_object)
- into :o_group_has_right;
- suspend;
- o_right_kind = 25;
- select o_result from get_right_groupright(:i_id_groupright,:o_right_kind,:o_id_object)
- into :o_group_has_right;
- suspend;
- end
- o_right_kind = 26;
- select o_result from get_right_groupright(:i_id_groupright,:o_right_kind,0)
- into :o_group_has_right;
- suspend;
- /* 27 права на общедоступные группы внешних пользователей */
- for select eeg.id, eeg.name, eeg.id_owner from email_employer_group eeg
- where eeg.isdeleted=0 and eeg.iscommon=1
- into :o_id_object, :o_objectname, :l_id_owner
- do
- begin
- if (l_id_owner=i_id_employer or l_id_owner is null ) then
- o_can_edit = 1;
- else
- o_can_edit = 0;
- o_right_kind = 27;
- select o_result from get_right_groupright(:i_id_groupright,:o_right_kind,:o_id_object)
- into :o_group_has_right;
- suspend;
- end
- end^
- SET TERM ; ^
- commit;
- EXECUTE PROCEDURE GIVE_GRANTS_TO_ALL('PROCEDURE','GET_RIGHTS_OF_GROUP_WORKFLOW','EXECUTE');
- commit;
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE GET_RIGHTS_OF_EMPLOYER_WORKFLOW (
- i_id_employer integer,
- i_id_viewed_empl integer,
- i_isusepersonalgroup smallint)
- returns (
- o_right_kind integer,
- o_id_object integer,
- o_objectname varchar(1000),
- o_id_groupright integer,
- o_groupright_name varchar(1000))
- as
- begin
- for select gr.id,gr.name from grouprights_employer gre
- left join grouprights gr on gr.id = gre.id_groupright
- where gre.id_employer = :i_id_viewed_empl and gr.isdeleted=0 and
- (gr.isvisible=1 or (:i_isusepersonalgroup=1)and(gr.isvisible=0))
- into :o_id_groupright,:o_groupright_name
- do
- begin
- for select grg.o_right_kind,grg.o_id_object,grg.o_objectname
- from get_rights_of_group_workflow(:i_id_employer,:o_id_groupright) grg
- where grg.o_group_has_right=1
- into :o_right_kind, :o_id_object, :o_objectname
- do
- suspend;
- end
- end^
- SET TERM ; ^
- commit;
- EXECUTE PROCEDURE GIVE_GRANTS_TO_ALL('PROCEDURE','GET_RIGHTS_OF_EMPLOYER_WORKFLOW','EXECUTE');
- commit;
- /* Выбор прав для docflow-версии (не возвращает права для задач) */
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE GET_RIGHTS_OF_GROUP_DOCFLOW (
- i_id_employer integer,
- i_id_groupright integer)
- returns (
- o_right_kind integer,
- o_id_object integer,
- o_objectname varchar(1000),
- o_group_has_right smallint,
- o_can_edit smallint)
- as
- declare variable l_id_owner integer;
- declare variable l_id_groupright integer;
- begin
- O_ID_OBJECT = 0;
- O_OBJECTNAME = '';
- for select gl.id
- from grouprights_list gl
- where gl.edition = 'docflow' or gl.edition is null
- into :O_RIGHT_KIND
- do
- begin
- select o_result from get_right_employer_and_group(:i_id_employer,:o_right_kind,0)
- into :o_can_edit;
- select o_result from get_right_groupright(:i_id_groupright,:o_right_kind,:o_id_object)
- into :o_group_has_right;
- suspend;
- end
- for select dt.id, dt.name, dt.id_owner from doctypes dt
- where dt.isdeleted=0
- into :o_id_object, :o_objectname, :l_id_owner
- do
- begin
- if (l_id_owner=i_id_employer or l_id_owner is null ) then
- o_can_edit = 1;
- else
- o_can_edit = 0;
- o_right_kind = 1;
- select o_result from get_right_groupright(:i_id_groupright,:o_right_kind,:o_id_object)
- into :o_group_has_right;
- suspend;
- o_right_kind = 2;
- select o_result from get_right_groupright(:i_id_groupright,:o_right_kind,:o_id_object)
- into :o_group_has_right;
- suspend;
- o_right_kind = 28; /* 28 - право выбора связанных документов */
- select o_result from get_right_groupright(:i_id_groupright,:o_right_kind,:o_id_object)
- into :o_group_has_right;
- suspend;
- end
- o_right_kind = 3;
- for select rt.id, rt.name, rt.id_owner from routetemplate rt
- where rt.isdeleted=0 and rt.kind=0
- into :o_id_object, :o_objectname, :l_id_owner
- do
- begin
- if (l_id_owner=i_id_employer or l_id_owner is null ) then
- o_can_edit = 1;
- else
- o_can_edit = 0;
- select o_result from get_right_groupright(:i_id_groupright,:o_right_kind,:o_id_object)
- into :o_group_has_right;
- suspend;
- end
- o_right_kind = 9;
- for select fd.id, fd.name, fd.id_owner from fdoctemplate fd
- where fd.isdeleted=0
- into :o_id_object, :o_objectname, :l_id_owner
- do
- begin
- if (l_id_owner=i_id_employer or l_id_owner is null ) then
- o_can_edit = 1;
- else
- o_can_edit = 0;
- select o_result from get_right_groupright(:i_id_groupright,:o_right_kind,:o_id_object)
- into :o_group_has_right;
- suspend;
- end
- o_right_kind = 10;
- if (I_ID_GROUPRIGHT is null) then L_ID_GROUPRIGHT=0;
- else
- L_ID_GROUPRIGHT=:I_ID_GROUPRIGHT;
- for select g.id, g.name, g.id_owner from grouprights g
- where g.isdeleted=0 and g.isvisible=1 and g.id<>:L_ID_GROUPRIGHT
- into :o_id_object, :o_objectname, :l_id_owner
- do
- begin
- if (l_id_owner=i_id_employer ) then
- o_can_edit = 1;
- else
- o_can_edit = 0;
- select o_result from get_right_groupright(:i_id_groupright,:o_right_kind,:o_id_object)
- into :o_group_has_right;
- suspend;
- end
- o_right_kind = 15;
- o_can_edit = 1;
- for select md.id, md.name, md.id_owner
- from meta_dictionary md
- where md.isdeleted=0 and md.id_owner=:i_id_employer and recordtype=1
- into :o_id_object, :o_objectname, :l_id_owner
- do
- begin
- select o_result from get_right_groupright(:i_id_groupright,:o_right_kind,:o_id_object)
- into :o_group_has_right;
- suspend;
- end
- /* 17 права на просмотр записей в справочнике */
- /* 18 права на добавление записей в справочник */
- /* 19 права на изменение записей в справочнике */
- /* 20 права на удаление записей в справочнике */
- o_can_edit = 1;
- for select md.id, md.name, md.id_owner
- from meta_dictionary md
- where md.isdeleted=0 and md.id_owner=:i_id_employer and recordtype=0
- into :o_id_object, :o_objectname, :l_id_owner
- do
- begin
- o_right_kind = 17;
- select o_result from get_right_groupright(:i_id_groupright,:o_right_kind,:o_id_object)
- into :o_group_has_right;
- suspend;
- o_right_kind = 18;
- select o_result from get_right_groupright(:i_id_groupright,:o_right_kind,:o_id_object)
- into :o_group_has_right;
- suspend;
- o_right_kind = 19;
- select o_result from get_right_groupright(:i_id_groupright,:o_right_kind,:o_id_object)
- into :o_group_has_right;
- suspend;
- o_right_kind = 20;
- select o_result from get_right_groupright(:i_id_groupright,:o_right_kind,:o_id_object)
- into :o_group_has_right;
- suspend;
- end
- -- плагины не привязвнные к типам
- o_right_kind = 77;
- for select plg.id, plg.name, plg.id_owner from plugins plg where plg.no_connect_to_type=1
- into :o_id_object, :o_objectname, :l_id_owner
- do
- begin
- if (l_id_owner=i_id_employer or l_id_owner is null ) then
- o_can_edit = 1;
- else
- o_can_edit = 0;
- select o_result from get_right_groupright(:i_id_groupright,:o_right_kind,:o_id_object)
- into :o_group_has_right;
- suspend;
- end
- /* 23 права на просмотр событий календаря */
- /* 24 права на добавление и редактирование событий в календарь */
- /* 25 полные права*/
- o_can_edit = 1;
- for select c.id, c.name, c.id_owner
- from calendars c
- where c.id_owner=:i_id_employer and is_system=0
- into :o_id_object, :o_objectname, :l_id_owner
- do
- begin
- o_right_kind = 23;
- select o_result from get_right_groupright(:i_id_groupright,:o_right_kind,:o_id_object)
- into :o_group_has_right;
- suspend;
- o_right_kind = 24;
- select o_result from get_right_groupright(:i_id_groupright,:o_right_kind,:o_id_object)
- into :o_group_has_right;
- suspend;
- o_right_kind = 25;
- select o_result from get_right_groupright(:i_id_groupright,:o_right_kind,:o_id_object)
- into :o_group_has_right;
- suspend;
- end
- o_right_kind = 26;
- select o_result from get_right_groupright(:i_id_groupright,:o_right_kind,0)
- into :o_group_has_right;
- suspend;
- /* 27 права на общедоступные группы внешних пользователей */
- for select eeg.id, eeg.name, eeg.id_owner from email_employer_group eeg
- where eeg.isdeleted=0 and eeg.iscommon=1
- into :o_id_object, :o_objectname, :l_id_owner
- do
- begin
- if (l_id_owner=i_id_employer or l_id_owner is null ) then
- o_can_edit = 1;
- else
- o_can_edit = 0;
- o_right_kind = 27;
- select o_result from get_right_groupright(:i_id_groupright,:o_right_kind,:o_id_object)
- into :o_group_has_right;
- suspend;
- end
- end^
- SET TERM ; ^
- commit;
- EXECUTE PROCEDURE GIVE_GRANTS_TO_ALL('PROCEDURE','GET_RIGHTS_OF_GROUP_DOCFLOW','EXECUTE');
- commit;
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE GET_RIGHTS_OF_EMPLOYER_DOCFLOW (
- i_id_employer integer,
- i_id_viewed_empl integer,
- i_isusepersonalgroup smallint)
- returns (
- o_right_kind integer,
- o_id_object integer,
- o_objectname varchar(1000),
- o_id_groupright integer,
- o_groupright_name varchar(1000))
- as
- begin
- for select gr.id,gr.name from grouprights_employer gre
- left join grouprights gr on gr.id = gre.id_groupright
- where gre.id_employer = :i_id_viewed_empl and gr.isdeleted=0 and
- (gr.isvisible=1 or (:i_isusepersonalgroup=1)and(gr.isvisible=0))
- into :o_id_groupright,:o_groupright_name
- do
- begin
- for select grg.o_right_kind,grg.o_id_object,grg.o_objectname
- from get_rights_of_group_docflow(:i_id_employer,:o_id_groupright) grg
- where grg.o_group_has_right=1
- into :o_right_kind, :o_id_object, :o_objectname
- do
- suspend;
- end
- end^
- SET TERM ; ^
- commit;
- EXECUTE PROCEDURE GIVE_GRANTS_TO_ALL('PROCEDURE','GET_RIGHTS_OF_EMPLOYER_DOCFLOW','EXECUTE');
- commit;
- /* добавляем атрибут "Версия" для видов событий, используемых в настройке оповещений */
- EXECUTE PROCEDURE ADD_FIELD_IF_DOES_NOT_EXIST('NOTIFICATION_PREFS', 'EDITION', 'VARCHAR(10)');
- RESULT
- =======
- 0
- commit;
- /* Заполняем поле "Версия" для видов событий, используемых в настройке оповещений */
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE TMP_FILL_NOTIF_PREFS_EDITION
- AS
- BEGIN
- UPDATE
- notification_prefs
- SET
- edition = 'docflow'
- WHERE
- action_type in (13, 14, 15, 16);
- UPDATE
- notification_prefs
- SET
- edition = 'workflow'
- WHERE
- action_type in (5, 10, 17);
- END ^
- SET TERM ; ^
- commit;
- EXECUTE PROCEDURE TMP_FILL_NOTIF_PREFS_EDITION;
- commit;
- DROP PROCEDURE TMP_FILL_NOTIF_PREFS_EDITION;
- commit;
- /* добавляем поле "Права на модули" в таблицу employer, значение которого будет определять доступные для пользователя модули в зависимости от лицензий */
- EXECUTE PROCEDURE ADD_FIELD_IF_DOES_NOT_EXIST('EMPLOYER', 'EDITION', 'VARCHAR(10)');
- RESULT
- =======
- 0
- commit;
- /* При обновлении с 1.2 все пользователи получают Complete*/
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE TMP_SET_COMPLETE_EDITION
- AS
- BEGIN
- UPDATE
- employer
- SET
- edition = 'complete'
- WHERE
- edition is null or edition = '';
- END ^
- SET TERM ; ^
- commit;
- EXECUTE PROCEDURE TMP_SET_COMPLETE_EDITION;
- commit;
- DROP PROCEDURE TMP_SET_COMPLETE_EDITION;
- commit;
- /*----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
- /* WORKFLOW/DOCFLOW/COMPLETE (окончание)
- /*----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
- /*----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
- /* Выделение цветом задач (начало)
- /*----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
- EXECUTE PROCEDURE ADD_FIELD_IF_DOES_NOT_EXIST('TASK_ATTRIBUTE_VALUES', 'COLOR', 'VARCHAR(7)');
- RESULT
- =======
- 0
- commit;
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE TMP_FILL_COLOR
- AS
- declare variable l_id_md integer;
- declare variable l_id_mf integer;
- declare variable l_task_id integer;
- declare variable l_nrecord_tasktype integer;
- declare variable l_color varchar(7);
- BEGIN
- FOR
- SELECT DISTINCT
- mv.id_md,
- mv.id_mf,
- t.id,
- t.nrecord_tasktype
- FROM
- meta_value mv
- JOIN
- meta_field mf ON (mf.id = mv.id_mf)
- JOIN
- task t ON (t.nrecord_tasktype = mv.id_record)
- WHERE
- mf.id_type_field = 8 AND
- mv.value_integer IN (SELECT
- mv1.id_record
- FROM
- meta_value mv1
- JOIN
- meta_field mf1 ON (mf1.id = mv1.id_mf)
- WHERE
- mv1.isdeleted = 0 AND
- mf1.isdeleted = 0 AND
- mf1.id_type_field = 13) AND
- mv.isdeleted = 0 AND
- t.isdeleted = 0
- INTO
- :l_id_md,
- :l_id_mf,
- :l_task_id,
- :l_nrecord_tasktype
- DO
- BEGIN
- SELECT
- mv.value_char
- FROM
- meta_value mv
- JOIN
- meta_field mf ON (mf.id = mv.id_mf)
- WHERE mv.id_record IN (SELECT
- mv1.value_integer
- FROM
- meta_value mv1
- JOIN
- meta_field mf1 ON (mf1.id = mv1.id_mf)
- WHERE
- mf1.id = :l_id_mf AND
- mv1.id_record = :l_nrecord_tasktype AND
- mv1.id_md = :l_id_md) AND
- mf.id_type_field = 13 AND
- mf.isdeleted = 0 AND
- mv.isdeleted = 0
- INTO
- :l_color;
- IF (l_color <> '') THEN
- BEGIN
- UPDATE
- task_attribute_values
- SET
- color = :l_color
- WHERE
- id_task = :l_task_id AND
- id_metafield = :l_id_mf;
- END
- END
- END ^
- SET TERM ; ^
- commit;
- EXECUTE PROCEDURE TMP_FILL_COLOR;
- commit;
- DROP PROCEDURE TMP_FILL_COLOR;
- commit;
- /*----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
- /* Выделение цветом задач (окончание)
- /*----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
- EXECUTE PROCEDURE ADD_INDEX_IF_DOES_NOT_EXIST('META_FIELD_IDX3', 'META_FIELD', 'ID_CONNECT');
- RESULT
- =======
- 0
- commit;
- EXECUTE PROCEDURE ADD_INDEX_IF_DOES_NOT_EXIST('IDX_FOLDERS_TASKS2', 'FOLDERS_TASKS', 'ID_EMPLOYER,ID_TASK,ID_FOLDER');
- RESULT
- =======
- 0
- commit;
- SET TERM ^ ;
- /*----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
- /* Добавила параметр disableSystemActions - Не уведомлять о системных действиях
- /*----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
- ALTER PROCEDURE INFORMER2_USERPARAMS (
- userid integer)
- returns (
- userclones varchar(2000),
- settings varchar(8000),
- markers varchar(2000),
- activityintervals varchar(2000),
- colorindication varchar(200),
- disablesystemactions integer)
- as
- declare variable id1 integer;
- begin
- UserClones=UserId;
- for select id
- from employer
- where ParentId=:UserId and
- isdeleted=0
- into :id1
- do UserClones=UserClones||','||id1;
- Settings = '';
- ACTIVITYINTERVALS = '';
- MARKERS = '';
- select e.informer_markers, e.colorindication
- from Employer e
- where id= :UserId
- into :MARKERS, :Colorindication;
- SELECT first 1 settings_value
- FROM employer_settings
- WHERE (settings_key='disableSystemActions') AND id_employer = :UserId
- into :disableSystemActions;
- suspend;
- end
- ^
- SET TERM ; ^
- commit;
- /*---------------------------------------------------------------------------------------------*/
- /*удаляем из меню «Дополнительные отчёты» и «Шаблоны отчётов»
- /*----------------------------------------------------------------------------------------------*/
- /*delete from menuitems where ((dmess_tagname = 'L_MENU_CREATE_TEMPLATE') or (dmess_tagname = 'L_MENU_OTHER_REPORTS'));
- commit;
- */
- /*уникальные теги для названий*/
- /*update menuitems mi set mi.dmess_tagname = 'L_MENU_ADMIN_MENUSETTINGS' where mi.item_id = 77;
- commit;
- update menuitems mi set mi.dmess_tagname = 'L_MENU_ADMIN_NOTIFICATION_SETTINGS' where mi.item_id = 74;
- commit;
- */
- /* добавляем поле "Напоминание только для меня" */
- EXECUTE PROCEDURE ADD_FIELD_IF_DOES_NOT_EXIST('NOTICE', 'ONLY_FOR_ME', 'SMALLINT');
- RESULT
- =======
- 0
- COMMIT;
- /* Пункты меню инструменты и сообщения */
- /*execute procedure ADDNEWMENUITEM (NULL,'L_MENU_TOOLS',NULL,0,3,1,0,NULL);
- execute procedure ADDNEWMENUITEM (NULL,'L_MENU_MESSAGES',NULL,0,6,1,0,NULL);
- COMMIT;
- */
- /* Новая структура меню */
- /*SET TERM ^ ;
- CREATE PROCEDURE UPDATE_MENU_4U13
- AS
- DECLARE VARIABLE id INTEGER;
- DECLARE VARIABLE ide INTEGER;
- BEGIN
- // Архив документов в документы
- for
- select mi.ID, mi.ID_EMPLOYER
- from MENUITEMS mi
- where mi.DMESS_TAGNAME='L_MENU_DOCS_ARCHIVE'
- into :id, :ide
- do
- begin
- update MENUITEMS set IDPARENT=
- (select first 1 mi.id
- from MENUITEMS mi
- where mi.DMESS_TAGNAME='L_MENU_DOCUMENTS' and
- mi.ID_EMPLOYER=:ide)
- where ID=:id;
- end
- // Архив задач в задачи /
- for
- select mi.ID, mi.ID_EMPLOYER
- from MENUITEMS mi
- where mi.DMESS_TAGNAME='L_MENU_TARCHIVE'
- into :id, :ide
- do
- begin
- update MENUITEMS set IDPARENT=
- (select first 1 mi.id
- from MENUITEMS mi
- where mi.DMESS_TAGNAME='L_MENU_TASKS' and
- mi.ID_EMPLOYER=:ide)
- where ID=:id;
- end
- Клиентские приложения в инструменты
- for
- select mi.ID, mi.ID_EMPLOYER
- from MENUITEMS mi
- where mi.DMESS_TAGNAME='L_MENU_SOME_PROGRAMMS'
- into :id, :ide
- do
- begin
- update MENUITEMS set IDPARENT=
- (select first 1 mi.id
- from MENUITEMS mi
- where mi.DMESS_TAGNAME='L_MENU_TOOLS' and
- mi.ID_EMPLOYER=:ide)
- where ID=:id;
- end
- Адресная книга в инструменты
- for
- select mi.ID, mi.ID_EMPLOYER
- from MENUITEMS mi
- where mi.DMESS_TAGNAME='L_ADDRESS_BOOK'
- into :id, :ide
- do
- begin
- update MENUITEMS set IDPARENT=
- (select first 1 mi.id
- from MENUITEMS mi
- where mi.DMESS_TAGNAME='L_MENU_TOOLS' and
- mi.ID_EMPLOYER=:ide)
- where ID=:id;
- end
- Отчеты в инструменты
- for
- select mi.ID, mi.ID_EMPLOYER
- from MENUITEMS mi
- where mi.DMESS_TAGNAME='L_MENU_REPORTS'
- into :id, :ide
- do
- begin
- update MENUITEMS set IDPARENT=
- (select first 1 mi.id
- from MENUITEMS mi
- where mi.DMESS_TAGNAME='L_MENU_TOOLS' and
- mi.ID_EMPLOYER=:ide)
- where ID=:id;
- end
- Проекты в инструменты
- for
- select mi.ID, mi.ID_EMPLOYER
- from MENUITEMS mi
- where mi.DMESS_TAGNAME='L_MENU_PROJECTS'
- into :id, :ide
- do
- begin
- update MENUITEMS set IDPARENT=
- (select first 1 mi.id
- from MENUITEMS mi
- where mi.DMESS_TAGNAME='L_MENU_TOOLS' and
- mi.ID_EMPLOYER=:ide)
- where ID=:id;
- end
- Администрирование в инструменты
- for
- select mi.ID, mi.ID_EMPLOYER
- from MENUITEMS mi
- where mi.DMESS_TAGNAME='L_MENU_ADMINISTRATION'
- into :id, :ide
- do
- begin
- update MENUITEMS set IDPARENT=
- (select first 1 mi.id
- from MENUITEMS mi
- where mi.DMESS_TAGNAME='L_MENU_TOOLS' and
- mi.ID_EMPLOYER=:ide)
- where ID=:id;
- end
- Администрирование ДО в инструменты
- for
- select mi.ID, mi.ID_EMPLOYER
- from MENUITEMS mi
- where mi.DMESS_TAGNAME='L_DOCPROCESSING'
- into :id, :ide
- do
- begin
- update MENUITEMS set IDPARENT=
- (select first 1 mi.id
- from MENUITEMS mi
- where mi.DMESS_TAGNAME='L_MENU_TOOLS' and
- mi.ID_EMPLOYER=:ide)
- where ID=:id;
- end
- Система безопасности в инструменты
- for
- select mi.ID, mi.ID_EMPLOYER
- from MENUITEMS mi
- where mi.DMESS_TAGNAME='L_MENU_SECURITY_SYSTEM'
- into :id, :ide
- do
- begin
- update MENUITEMS set IDPARENT=
- (select first 1 mi.id
- from MENUITEMS mi
- where mi.DMESS_TAGNAME='L_MENU_TOOLS' and
- mi.ID_EMPLOYER=:ide)
- where ID=:id;
- end
- Настройки в инструменты
- for
- select mi.ID, mi.ID_EMPLOYER
- from MENUITEMS mi
- where mi.DMESS_TAGNAME='L_AU_MENU_SETTINGS'
- into :id, :ide
- do
- begin
- update MENUITEMS set IDPARENT=
- (select first 1 mi.id
- from MENUITEMS mi
- where mi.DMESS_TAGNAME='L_MENU_TOOLS' and
- mi.ID_EMPLOYER=:ide)
- where ID=:id;
- end
- Архив проектов в проекты
- for
- select mi.ID, mi.ID_EMPLOYER
- from MENUITEMS mi
- where mi.DMESS_TAGNAME='L_MENU_PARCHIVE'
- into :id, :ide
- do
- begin
- update MENUITEMS set IDPARENT=
- (select first 1 mi.id
- from MENUITEMS mi
- where mi.DMESS_TAGNAME='L_MENU_PROJECTS' and
- mi.ID_EMPLOYER=:ide)
- where ID=:id;
- end
- Мои сообщения в сообщения
- for
- select mi.ID, mi.ID_EMPLOYER
- from MENUITEMS mi
- where mi.DMESS_TAGNAME='L_MENU_UIONSENDEDIT'
- into :id, :ide
- do
- begin
- update MENUITEMS set IDPARENT=
- (select first 1 mi.id
- from MENUITEMS mi
- where mi.DMESS_TAGNAME='L_MENU_MESSAGES' and
- mi.ID_EMPLOYER=:ide)
- where ID=:id;
- end
- Порядок пунктов меню
- update MENUITEMS mi
- set mi.NUMBER=1
- WHERE mi.DMESS_TAGNAME='L_MENU_TASKS';
- update MENUITEMS mi
- set mi.NUMBER=2
- WHERE mi.DMESS_TAGNAME='L_MENU_DOCUMENTS';
- update MENUITEMS mi
- set mi.NUMBER=3
- WHERE mi.DMESS_TAGNAME='L_MENU_MESSAGES';
- update MENUITEMS mi
- set mi.NUMBER=4
- WHERE mi.DMESS_TAGNAME='L_GLOBAL_CALENDAR';
- update MENUITEMS mi
- set mi.NUMBER=5
- WHERE mi.DMESS_TAGNAME='L_MENU_DOCLIBRARY';
- update MENUITEMS mi
- set mi.NUMBER=6
- WHERE mi.DMESS_TAGNAME='L_MENU_TOOLS';
- update MENUITEMS mi
- set mi.NUMBER=1
- WHERE mi.DMESS_TAGNAME='L_INFORMER_CREATETASK';
- update MENUITEMS mi
- set mi.NUMBER=2
- WHERE mi.DMESS_TAGNAME='L_MENU_UNIONTASKS';
- update MENUITEMS mi
- set mi.NUMBER=3
- WHERE mi.DMESS_TAGNAME='L_MENU_ONCONTROL';
- update MENUITEMS mi
- set mi.NUMBER=4
- WHERE mi.DMESS_TAGNAME='L_MENU_TASKSANDEMP';
- update MENUITEMS mi
- set mi.NUMBER=5
- WHERE mi.DMESS_TAGNAME='L_MENU_TARCHIVE';
- delete from MENUITEMS mi
- WHERE mi.DMESS_TAGNAME='L_MENU_MYTASKS';
- delete from MENUITEMS mi
- WHERE mi.DMESS_TAGNAME='L_MENU_TASKSFROMME';
- update MENUITEMS mi
- set mi.NUMBER=1
- WHERE mi.DMESS_TAGNAME='L_DOCUMENT_NEW';
- update MENUITEMS mi
- set mi.NUMBER=2
- WHERE mi.DMESS_TAGNAME='L_MENU_MYDOCS_FORASSIGNMENT';
- update MENUITEMS mi
- set mi.NUMBER=3
- WHERE mi.DMESS_TAGNAME='L_MENU_MYDOCS_FOREXECUTION';
- update MENUITEMS mi
- set mi.NUMBER=4
- WHERE mi.DMESS_TAGNAME='L_MENU_DOCS_ONASSIGNMENT';
- update MENUITEMS mi
- set mi.NUMBER=5
- WHERE mi.DMESS_TAGNAME='L_MENU_DOCS_ONEXECUTION';
- update MENUITEMS mi
- set mi.NUMBER=6
- WHERE mi.DMESS_TAGNAME='L_MENU_DOCS_FROMME';
- update MENUITEMS mi
- set mi.NUMBER=7
- WHERE mi.DMESS_TAGNAME='L_MENU_DOCS_REGISTRY';
- update MENUITEMS mi
- set mi.NUMBER=8
- WHERE mi.DMESS_TAGNAME='L_MENU_DOCS_DETAL_REGISTRY_COUNTERS';
- update MENUITEMS mi
- set mi.NUMBER=9
- WHERE mi.DMESS_TAGNAME='L_MENU_DOCUMENT_STATISTIC';
- update MENUITEMS mi
- set mi.NUMBER=10
- WHERE mi.DMESS_TAGNAME='L_MENU_DOCS_REPORT';
- update MENUITEMS mi
- set mi.NUMBER=11
- WHERE mi.DMESS_TAGNAME='L_MENU_DOCS_ARCHIVE';
- update MENUITEMS mi
- set mi.url='/user/notices/'
- where mi.DMESS_TAGNAME='L_MENU_UIONSENDEDIT';
- update MENUITEMS mi
- set mi.NUMBER=23
- WHERE mi.DMESS_TAGNAME='L_MENU_ADRESSBOOK_SETTINGS';
- update MENUITEMS mi
- set mi.NUMBER=16
- WHERE mi.DMESS_TAGNAME='L_GLOBAL_USE_STATISTIC';
- update MENUITEMS mi
- set mi.NUMBER=10
- WHERE mi.DMESS_TAGNAME='L_GLOBAL_EMAIL_EMPLOYER_GROUPS';
- update MENUITEMS mi
- set mi.NUMBER=4
- WHERE mi.DMESS_TAGNAME='L_SEARCHING_DOCUMENTS';
- update MENUITEMS mi
- set mi.NUMBER=5
- WHERE mi.DMESS_TAGNAME='L_MENU_PARCHIVE';
- /*Права на пункты меню начало*/
- /*администрирование*/
- /*показывать группу "администрирование" если начальник, любой админ, право на создание типов задач или право
- на просмотр записей справочников или на администрирование справочников*/
- --update menuitems mi set mi.right_kind = 11 where mi.dmess_tagname = 'L_MENU_ADMINISTRATION';
- /*администрирование до для админов до*/
- --update menuitems mi set mi.right_kind = 4 where mi.dmess_tagname = 'L_DOCPROCESSING';
- /*система безопастности*/
- /*по идее, должен быть доступен любому админу - есть пункт "отчет по удаленным документам", но при ситуации
- когда кто-то админ библиотеки и workflow меню виснет - группа видна из-за этого пункта для любого админа, а ему
- нелизя ничего связанного с документами. поэтому 12 - все админы, но админ библиотеки еще и не workflow*/
- --update menuitems mi set mi.right_kind = 12 where mi.dmess_tagname = 'L_MENU_SECURITY_SYSTEM';
- /*функционал формализованных документов*/
- /*видимый для админа до при включенной опции формализованных документов*/
- --update menuitems mi set mi.right_kind = 13 where mi.dmess_tagname = 'L_MENU_FORMALDOCUMENT_TEMPLATE_EDITOR';
- /*вроде как для шаблонов документов используется этот тег и ид*/
- --update menuitems mi set mi.right_kind = 13 where mi.dmess_tagname = 'L_AU_DOCUMENT_TEMPLATE_EDITOR';
- /*но у нас на бете для всех юзеров еще и этот пункт есть. заменим и тут*/
- --update menuitems mi set mi.right_kind = 13 where mi.dmess_tagname = 'L_MENU_FORMALDOCUMENT_TEMPLATE_EDITOR';
- /*удаляем из администрирования "объявления"*/
- --delete from menuitems mi where mi.dmess_tagname ='L_MENU_NOTICES';
- /* удаляем лишние пункты меню проекты */
- --delete from menuitems mi where mi.dmess_tagname = 'L_MENU_PROJECTS' and ((mi.item_id > 0) or (mi.idparent is null));
- /*у некоторых пользователей откуда-то взялся лишний пункт "поиск"*/
- --delete from menuitems mi where mi.dmess_tagname = 'L_GLOBAL_SEARCH' and mi.number = 13;
- /*удаляем пункт "архивы"*/
- --delete from menuitems mi where mi.dmess_tagname = 'L_MENU_ARCHIVES';
- /*лишний пунк администрирование в настройках по умолчанию*/
- --delete from menuitems m where m.dmess_tagname = 'L_MENU_ADMINISTRATION' and m.isdefvisible is null and m.id_employer = -1;
- /*в двух отчетах не стоят слеши в адресах, поэтому они не открываются. фиксим*/
- /*статистика по задачам пользователя*/
- --update menuitems mi set mi.url = '/user/prereporttasksonperiod/' where mi.dmess_tagname = 'L_MENU_TASKS_ON_PERIOD';
- /*общий отчет по пользователям*/
- --update menuitems mi set mi.url = '/user/user_report/' where mi.dmess_tagname = 'L_GLOBAL_USERS_REPORT';
- /*адрессная книга теперь не группа, ей нуже ид*/
- --update menuitems m set m.item_id = 32 where m.dmess_tagname = 'L_ADDRESS_BOOK';
- /*Права на пункты меню конец*/
- /* удаляем пункты меню Настройки - Фильтры подразделений и Настройки - Группы */
- /*delete from MENUITEMS mi where mi.DMESS_TAGNAME = 'L_MENU_USER_DEPARTMENT';
- delete from MENUITEMS mi where mi.DMESS_TAGNAME = 'L_MENU_GROUPS';
- delete from MENUITEMS mi where mi.DMESS_TAGNAME = 'L_MENU_NOTICES';
- END^
- SET TERM ; ^
- COMMIT;
- EXECUTE PROCEDURE UPDATE_MENU_4U13;
- COMMIT;
- DROP PROCEDURE UPDATE_MENU_4U13;
- COMMIT;
- */
- /*-------------------------------------------------------------------------------------------------------------------------------*/
- /*После того, как меню стало не иерархичным, информации из ADDNEWMENUITEM недостаточно
- для идентификации родительского элемента там использовалась пара "позиция в группе+нет родителя", теперь это не уникальное значение
- получается,
- в этой процедуре добавляем пункт в меню по тегу группы*/
- /*-------------------------------------------------------------------------------------------------------------------------------*/
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE ADDMENUITEMBYTAG (
- i_item_id integer,
- i_dmess_tagname varchar(200),
- i_url varchar(1000),
- i_parent_tag varchar(200),/*тег родительской группы*/
- i_number smallint,
- i_isdefvisible smallint,
- i_right_kind smallint,
- i_edition varchar(10))
- as
- declare variable l_id_employer integer;
- declare variable l_idparent integer;
- begin
- l_idparent = null;
- select first 1 id from menuitems m where m.item_id is null and m.id_employer=0 and m.dmess_tagname=:i_parent_tag
- into :l_idparent;
- /*если такого пункта нет, или он не группа ничего не добавляем*/
- if (l_idparent is null) then
- exit;
- else
- /*если уже есть с таким идшником, то не добавляем*/
- if (exists(select id
- from menuitems
- where item_id=:i_item_id)) then exit;
- update menuitems m
- set m.number = m.number + 1
- where m.id_employer=0 and m.idparent=:l_idparent and m.number>=:i_number;
- /*достаем экземпляр группы отдельно для -1*/
- select first 1 id from menuitems m where m.item_id is null and m.id_employer=-1 and m.dmess_tagname=:i_parent_tag
- into :l_idparent;
- insert into menuitems (item_id,dmess_tagname,url,idparent,number,
- isdefvisible,right_kind,id_employer,edition)
- values (:i_item_id, :i_dmess_tagname, :i_url, :l_idparent, :i_number,
- :i_isdefvisible, :i_right_kind, -1, :i_edition);
- /*и для 0*/
- select first 1 id from menuitems m where m.item_id is null and m.id_employer=0 and m.dmess_tagname=:i_parent_tag
- into :l_idparent;
- insert into menuitems (item_id,dmess_tagname,url,idparent,number,
- isdefvisible,right_kind,id_employer,edition)
- values (:i_item_id, :i_dmess_tagname, :i_url, :l_idparent, :i_number,
- :i_isdefvisible, :i_right_kind, 0, :i_edition);
- /*и для каждого юзера*/
- for select e.id from employer e
- where e.isdeleted=0 and e.parentid is null and
- (exists (select first 1 m.id from menuitems m where m.id_employer=e.id and m.dmess_tagname=:i_parent_tag))
- into :l_id_employer
- do
- begin
- select first 1 id from menuitems m
- where m.item_id is null and m.id_employer=:l_id_employer and m.dmess_tagname=:i_parent_tag
- into :l_idparent;
- update menuitems m
- set m.number = m.number + 1
- where m.id_employer=:l_id_employer and m.idparent=:l_idparent and m.number>=:i_number;
- insert into menuitems (item_id,dmess_tagname,url,idparent,number,
- right_kind,id_employer,edition)
- values (:i_item_id, :i_dmess_tagname, :i_url, :l_idparent, :i_number,
- :i_right_kind, :l_id_employer, :i_edition);
- end
- end^
- SET TERM ; ^
- commit;
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE COPYMENUITEMS (
- i_id_employer integer)
- as
- /*процедура копирует пункты меню пользователя 0 для нового пользователя*/
- /*пункты из корня*/
- declare variable l_id integer;
- declare variable l_item_id integer;
- declare variable l_dmess_tagname varchar(200);
- declare variable l_url varchar(1000);
- declare variable l_number smallint;
- declare variable l_isvisible smallint;
- declare variable l_right_kind smallint;
- declare variable l_edition varchar(10);
- /*пункты первого уровня*/
- declare variable l_id2 integer;
- declare variable l_item_id2 integer;
- declare variable l_dmess_tagname2 varchar(200);
- declare variable l_url2 varchar(1000);
- declare variable l_number2 smallint;
- declare variable l_isvisible2 smallint;
- declare variable l_isdefvisible2 smallint;
- declare variable l_right_kind2 smallint;
- declare variable l_edition2 varchar(10);
- /*пункты второго уровня*/
- declare variable l_id3 integer;
- declare variable l_item_id3 integer;
- declare variable l_dmess_tagname3 varchar(200);
- declare variable l_url3 varchar(1000);
- declare variable l_number3 smallint;
- declare variable l_isvisible3 smallint;
- declare variable l_isdefvisible3 smallint;
- declare variable l_right_kind3 smallint;
- declare variable l_edition3 varchar(10);
- /*РіСЂСѓРїРїР° РІ РєРѕСЂРЅРµ*/
- declare variable l_id_new integer;
- /*группа первого уровня*/
- declare variable l_sub_id_new integer;
- begin
- /*копируем корневые элементы*/
- for select
- m.id, m.item_id, m.dmess_tagname, m.url, m.number,
- m.isvisible, m.right_kind, m.edition
- from menuitems m
- where m.id_employer=0 and m.idparent=0
- into :l_id,:l_item_id,:l_dmess_tagname,:l_url,:l_number,
- :l_isvisible,:l_right_kind,:l_edition
- do
- begin
- l_id_new = gen_id(gen_menuitems_id,1);
- insert into menuitems (id,item_id,dmess_tagname,url,number,isvisible,right_kind,id_employer,edition)
- values (:l_id_new,:l_item_id,:l_dmess_tagname,:l_url,:l_number,:l_isvisible,:l_right_kind,:i_id_employer,:l_edition);
- /*коприруем элементы первого уровня*/
- for select
- m.id, m.item_id, m.dmess_tagname, m.url, m.number,
- m.isvisible, m.isdefvisible, m.right_kind, m.edition
- from menuitems m
- where m.id_employer=0 and m.idparent=:l_id
- into :l_id2,:l_item_id2,:l_dmess_tagname2,:l_url2,:l_number2,
- :l_isvisible2,:l_isdefvisible2,:l_right_kind2,:l_edition2
- do
- begin
- l_sub_id_new = gen_id(gen_menuitems_id,1);
- insert into menuitems (id,item_id,dmess_tagname,url,number,isvisible,right_kind,idparent,id_employer,edition)
- values (:l_sub_id_new,:l_item_id2,:l_dmess_tagname2,:l_url2,:l_number2,:l_isvisible2,:l_right_kind2,:l_id_new,:i_id_employer,:l_edition2);
- if (l_item_id2 is null) then /*и для тех, у кого есть потомки*/
- for select/*коприруем элементы второго уровня*/
- m.id, m.item_id, m.dmess_tagname, m.url, m.number,
- m.isvisible, m.isdefvisible, m.right_kind, m.edition
- from menuitems m
- where m.id_employer=0 and m.idparent=:l_id2
- into :l_id3,:l_item_id3,:l_dmess_tagname3,:l_url3,:l_number3,
- :l_isvisible3,:l_isdefvisible3,:l_right_kind3,:l_edition3
- do
- begin
- insert into menuitems (item_id,dmess_tagname,url,number,isvisible,right_kind,idparent,id_employer,edition)
- values (:l_item_id3,:l_dmess_tagname3,:l_url3,:l_number3,:l_isvisible3,:l_right_kind3,:l_sub_id_new,:i_id_employer,:l_edition3);
- end
- end
- end
- end^
- SET TERM ; ^
- commit;
- /*-------------------------------------------------------------------------------------------------------------------------------*/
- /* Копирование пунктов меню - конец*/
- /*-------------------------------------------------------------------------------------------------------------------------------*/
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE GETALLNOTICES (
- i_employer_id integer,
- i_date timestamp)
- returns (
- o_notice_id integer,
- o_noticename varchar(200),
- o_author_id integer,
- o_authorname varchar(200),
- o_createdate timestamp,
- o_showdate timestamp,
- o_employercount integer,
- o_employerviewed integer,
- o_noticetype integer,
- o_description varchar(10000),
- o_id_task integer,
- o_place varchar(200),
- o_isshowtasklink smallint,
- o_is_view integer)
- as
- declare variable l_result integer;
- begin
- for select /*distinct*/
- n.id,
- n.name,
- n.id_author,
- (select name from employer e where e.id = n.id_author),
- n.createdate,
- n.showdate,
- n.noticetype,
- n.description,
- n.id_task,
- n.place,
- n.isshowtasklink
- from notice n
- where n.isdeleted=0 and ((n.id_author=:i_employer_id and (n.noticetype = 1 or n.noticetype = 3 or n.noticetype = 0)) or
- n.id in (select ntv.id_notice from noticeview ntv where ntv.id_employer=:i_employer_id and ntv.isviewed = 0 and ntv.showdate <= :i_date))
- /*((ntv.id_employer=:i_employer_id and ntv.isviewed = 0) or n.id_author=:i_employer_id)*/
- into
- :o_notice_id,
- :o_noticename,
- :o_author_id,
- :o_authorname,
- :o_createdate,
- :o_showdate,
- :o_noticetype,
- :o_description,
- :o_id_task,
- :o_place,
- :o_isshowtasklink
- do
- begin
- /*if (o_employercount is null) then
- o_employercount=0;
- o_employercount = o_employercount+1; */
- o_employercount=0;
- select count(*)
- from noticeview nw
- where nw.id_notice=:o_notice_id
- into :o_employercount;
- o_employerviewed=0;
- select count(*)
- from noticeview nw
- where nw.id_notice=:o_notice_id and nw.isviewed=1
- into :o_employerviewed;
- select count(*)
- from noticeview nw
- where nw.id_notice=:o_notice_id and id_employer=:i_employer_id and isviewed = 0 and nw.showdate <= :i_date
- into :o_is_view;
- suspend;
- end
- end^
- SET TERM ; ^
- commit;
- /*-------------------------------------------------------------------------------------------------------------------------------*/
- /*у пользователя по умолчанию -1 путаница с меню. началась еще с древних версий каких-то . чистим теперь*/
- /*-------------------------------------------------------------------------------------------------------------------------------*/
- /*SET TERM ^ ;
- CREATE OR ALTER PROCEDURE CLEANDEFMENUSET
- as
- declare variable l_tag_parent varchar(200);
- declare variable l_id_parant integer;
- declare variable l_tag_item varchar(200);
- declare variable l_id_item integer;
- begin
- for select m.id, m.dmess_tagname
- from menuitems m
- where m.id_employer = -1 and m.idparent not in
- (select n.id from menuitems n where n.id_employer = -1)
- and m.idparent <> 0
- into
- :l_id_item,
- :l_tag_item
- do
- begin
- select first 1 m.idparent from menuitems m where m.id_employer = 0 and m.dmess_tagname = :l_tag_item
- into
- :l_id_parant;
- select first 1 m.dmess_tagname from menuitems m where m.id_employer = 0 and m.id = :l_id_parant
- into
- :l_tag_parent;
- update menuitems n set n.idparent = (select first 1 m.id from menuitems m
- where m.id_employer = -1 and m.dmess_tagname = :l_tag_parent)
- where n.id = :l_id_item and n.id_employer = -1;
- end
- end^
- SET TERM ; ^
- commit;
- execute procedure cleandefmenuset;
- commit;
- */
- EXECUTE PROCEDURE ADD_INDEX_IF_DOES_NOT_EXIST('IDX_ACTIONS1','ACTIONS','ID_PARENT_ACTION');
- RESULT
- =======
- 0
- COMMIT;
- /* Уникальные логины в системе */
- CREATE OR ALTER EXCEPTION eBadLogin 'Login already exists';
- SET TERM ^ ;
- CREATE OR ALTER TRIGGER EMPLOYER_BIU FOR EMPLOYER
- ACTIVE BEFORE INSERT OR UPDATE POSITION 0
- AS
- DECLARE lUserId INTEGER;
- BEGIN
- IF (NEW.parentid IS NULL AND NEW.id <> OLD.id) THEN
- BEGIN
- SELECT id
- FROM employer e
- WHERE e.login = NEW.login AND
- e.parentid IS NULL AND
- e.isdeleted = 0
- INTO :lUserId;
- IF (:lUserId IS NOT NULL) THEN EXCEPTION eBadLogin;
- END
- END^
- SET TERM ; ^
- COMMIT;
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE GETDOCUMENTS_ARCHIVE_MY (
- i_employer_id integer,
- i_createdate_from timestamp,
- i_createdate_to timestamp)
- returns (
- o_doc_type integer,
- o_docid integer,
- o_is_right_arhiv integer) /*1 если попадает, 0 - нет*/
- as
- declare variable is_emplouer integer; /*есть права на автора*/
- declare variable is_autor integer; /*есть права на участника задач по документу*/
- begin
- for select d.id, (select p.ID_Boss
- from permission p
- where p.ID_Boss = :i_employer_id
- and p.ID_Employer = d.id_author
- and p.enabled = 1
- ), d.id_doctype
- from documents d
- where d.createdate >= :i_createdate_from and d.createdate <= :i_createdate_to
- and d.state = 4 and d.isdeleted = 0
- into :o_docid,
- :is_autor,
- :o_doc_type
- do
- /*----------------------------------------------------------------------------------------*/
- /*если есть права на атора документа, то все, в архив попадает*/
- if (is_autor <> 0) then
- begin
- O_IS_RIGHT_ARHIV = 1;
- suspend;
- end
- /*----------------------------------------------------------------------------------------*/
- /*если нет, проверяем права на участников задач по документу (с ботами блин)*/
- else
- begin
- select count (g.task_id_document)
- from grouptask g
- where g.task_id_document = :o_docid
- and g.id_employer in (select p.id_employer from permission p
- where p.id_boss = :i_employer_id
- and p.enabled = 1)
- into :is_emplouer;
- /*----------------------------------------------------------------------------------------*/
- /*если подходящие задачи есть, то все ок, попадает в отчет*/
- if (is_emplouer <> 0) then
- begin
- O_IS_RIGHT_ARHIV = 1;
- end
- /*----------------------------------------------------------------------------------------*/
- /*если нет, то без вариантов - этого документа в отчете нет*/
- else
- begin
- O_IS_RIGHT_ARHIV = 0;
- end
- suspend;
- end
- end^
- SET TERM ; ^
- commit;
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE MENUTRESH
- as
- declare variable var_emp integer;
- declare variable chest_first_time integer;
- begin
- --проверка: если у "создать задачу" ид = 101, то эта процедура уже выполнялась и больше не надо
- for select m.item_id from menuitems m
- where m.id_employer = 0 and m.dmess_tagname = 'L_INFORMER_CREATETASK'
- into :chest_first_time
- do
- begin
- if (chest_first_time = 101) then exit;
- end
- --дропаем таблицу
- delete from menuitems;
- chest_first_time = GEN_ID(GEN_MENUITEMS_ID, -GEN_ID(GEN_MENUITEMS_ID, 0));
- chest_first_time = GEN_ID(GEN_MENUITEMS_ID, 1000);
- --правильное меню
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (10, NULL, 'L_MENU_TASKS', NULL, 0, 1, 1, 1, 0, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (20, NULL, 'L_MENU_IAP', NULL, 0, 2, 1, 1, 30, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (30, NULL, 'L_MENU_IAP_PROJECT', 'l_menu_iap_project_adress', 0, 3, 1, 1, 30, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (40, NULL, 'L_MENU_DOCUMENTS', NULL, 0, 4, 1, 1, 0, 0, 'docflow');
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (50, NULL, 'L_MENU_MESSAGES', NULL, 0, 5, 1, 1, 0, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (60, NULL, 'L_GLOBAL_CALENDAR', '/user/calendarreportsel', 0, 6, 1, 1, 0, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (70, NULL, 'L_MENU_DOCLIBRARY', NULL, 0, 7, 1, 1, 0, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (80, NULL, 'L_MENU_TOOLS', NULL, 0, 8, 1, 1, 0, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (90, NULL, 'L_ADDITIONAL', NULL, 0, 9, 1, 1, 0, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (95, NULL, 'L_GLOBAL_SEARCH', NULL, 0, 10, 1, 1, 0, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (101, 101, 'L_INFORMER_CREATETASK', '/user/tasks//add/create_task/', 10, 2, 1, 1, 0, 0, 'workflow');
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (102, 102, 'L_MENU_UNIONTASKS', '/user/uniontasks/', 10, 1, 1, 1, 0, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (103, 103, 'L_MENU_ONCONTROL', '/user/formycontrol', 10, 5, 1, 0, 0, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (104, 104, 'L_MENU_TASKSANDEMP', '/user/tasks/', 10, 3, 1, 1, 0, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (105, 105, 'L_MENU_TARCHIVE', '/user/prereport/archive/', 10, 4, 1, 1, 0, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (201, 201, 'L_MENU_IAP_TASKS', '/user/tasksreports_grid/iap_message/', 20, 1, 1, 1, 30, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (202, 202, 'L_MENU_TABLE_TYPES', 'l_menu_table_types_adress', 20, 2, 1, 1, 30, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (203, 201, 'L_MENU_IAP_ADMINISTRATION', '/motiw4/Motiw4/Motiw4.html?sessionover=1', 20, 3, 1, 1, 30, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (401, 401, 'L_MENU_MYDOCS_FORASSIGNMENT', '/documents/mysigndocuments2/grid/mysigndocuments', 40, 1, 1, 1, 0, 0, 'docflow');
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (402, 402, 'L_MENU_MYDOCS_FOREXECUTION', '/documents/mysigndocuments2/grid/myexecdocuments', 40, 2, 1, 1, 0, 0, 'docflow');
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (403, 403, 'L_MENU_DOCS_ONASSIGNMENT', '/user/prereport/signdocuments2/', 40, 3, 1, 1, 2, 0, 'docflow');
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (404, 404, 'L_MENU_DOCS_ONEXECUTION', '/user/prereport/execdocuments2/', 40, 4, 1, 1, 2, 0, 'docflow');
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (405, 405, 'L_DOCUMENT_NEW', '/documents/newdocument/', 40, 5, 1, 1, 1, 0, 'docflow');
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (406, 406, 'L_MENU_DOCS_FROMME', '/documents/mysigndocuments2/grid/signdocumentsfromme', 40, 6, 1, 1, 1, 0, 'docflow');
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (407, 407, 'L_MENU_DOCS_REGISTRY', '/user/prereport/documents_registry2/', 40, 7, 1, 1, 2, 0, 'docflow');
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (408, 408, 'L_MENU_DOCS_DETAL_REGISTRY_COUNTERS', '/user/prereport/documents_registry_detal', 40, 8, 1, 1, 2, 0, 'docflow');
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (409, 409, 'L_MENU_DOCS_REPORT', '/user/prereport/report_documents/', 40, 9, 1, 1, 2, 0, 'docflow');
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (410, 410, 'L_MENU_DOCUMENT_STATISTIC', '/user/prereport/documents_statistic', 40, 10, 1, 1, 4, 0, 'docflow');
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (411, 411, 'L_MENU_DOCS_ARCHIVE', '/user/prereport_seldoctype/document_archive/', 40, 11, 1, 1, 22, 0, 'docflow');
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (701, 701, 'L_GLOBAL_DL_VIEW_DOCLIB', '/user/doclibview', 70, 1, 1, 1, 0, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (702, 702, 'L_GLOBAL_DL_CREATE_EDIT_FOLDER', '/user/createdltree', 70, 2, 1, 1, 0, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (703, 703, 'L_GLOBAL_DL_CHANGE_RIGHTS_TO_FOLDER', '/user/dlpermission', 70, 3, 1, 1, 0, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (704, 704, 'L_USER_RIGHTS_ON_DLFOLDER', '/user/userrightsondlfolder', 70, 4, 1, 1, 0, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (81, 81, 'L_ADDRESS_BOOK', '/user/tree_address_book', 80, 1, 1, 1, 0, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (82, NULL, 'L_MENU_REPORTS', NULL, 80, 2, 1, 1, 0, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (83, NULL, 'L_MENU_PROJECTS', NULL, 80, 3, 1, 1, 0, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (84, NULL, 'L_MENU_ADMINISTRATION', NULL, 80, 4, 1, 1, 11, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (86, NULL, 'L_DOCPROCESSING', NULL, 80, 5, 1, 1, 4, 0, 'docflow');
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (87, NULL, 'L_MENU_SECURITY_SYSTEM', NULL, 80, 6, 1, 1, 12, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (88, NULL, 'L_AU_MENU_SETTINGS', NULL, 80, 7, 1, 1, 0, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (89, 503, 'L_MENU_SOME_PROGRAMMS', '/user/some_programms/', 80, 8, 1, 1, 0, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (821, 821, 'L_MENU_ACTIONTAPE', '/user/prereport/report1/', 82, 1, 1, 1, 0, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (822, 822, 'L_MENU_ACTONMYTASKS', '/user/prereport/report8/', 82, 2, 1, 1, 0, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (823, 823, 'L_MENU_TASK_SUPERREPORT', '/user/prereport_selusers/tasksuperreport', 82, 3, 1, 1, 0, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (824, 824, 'L_GLOBAL_USERS_REPORT', '/user/user_report/', 82, 4, 1, 0, 0, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (825, 825, 'L_MENU_CUREMPTASKS', '/user/prereport_selusers/currentusertasks/', 82, 5, 1, 1, 0, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (826, 826, 'L_MENU_TASKSPERDIV', '/user/report4/', 82, 6, 1, 1, 0, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (827, 827, 'L_MENU_OUTDATEDTASKS', '/user/prereport/r_outdated/', 82, 7, 1, 1, 0, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (828, 828, 'L_MENU_TASKS_ON_PERIOD', '/user/prereporttasksonperiod/', 82, 8, 1, 1, 0, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (829, 829, 'L_REPORT_EXEC_BUT_OUTDATES', '/user/prereport/exec_but_outdate/', 82, 9, 1, 1, 0, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (830, 830, 'L_MENU_USERPROPS', '/user/report_users/', 82, 10, 1, 1, 0, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (831, 831, 'L_AU_PERMISSIONS_OF_EMPLOYER', '/user/whohasrights', 82, 11, 1, 1, 0, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (832, 832, 'L_GLOBAL_USER_REPORTS', '/user/free_plugins', 82, 12, 1, 0, 0, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (833, 833, 'L_MENU_SUB_PROJECTS', '/user/projects/', 83, 1, 1, 1, 0, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (834, 834, 'L_MENU_PNAVIGATION', '/user/pnavigation/', 83, 2, 1, 1, 0, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (835, 835, 'L_MENU_PARCHIVE', '/user/archiveprojects/', 83, 3, 1, 1, 0, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (841, 841, 'L_MENU_SYSTEMOPTIONS', '/user/systemoptions/', 84, 1, 1, 1, 6, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (842, 842, 'L_MENU_DEPADMIN', '/user/createtree/', 84, 2, 1, 1, 3, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (843, 843, 'L_MENU_USERADMIN', '/user/createuser/', 84, 3, 1, 1, 3, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (844, 844, 'L_GLOBAL_USER_PROFILES', '/user/UserProfiles/', 84, 4, 1, 1, 6, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (845, 845, 'L_BOTS', '/user/bots/', 84, 5, 1, 1, 6, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (846, 846, 'L_MENU_GROUPRIGHTS', '/user/groupsrights/', 84, 6, 1, 1, 9, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (847, 847, 'L_MENU_USERRIGHTS', '/user/userrights/', 84, 7, 1, 1, 9, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (848, 848, 'L_MENU_PERM', '/user/permission/', 84, 8, 1, 1, 3, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (849, 849, 'L_MENU_ADMIN_MENUSETTINGS', '/user/menusettings/', 84, 9, 1, 1, 6, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (850, 850, 'L_MENU_ADMIN_TYPE_TASK', '/user/tasktypelist/', 84, 10, 1, 1, 16, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (851, 851, 'L_GLOBAL_TASK_COUNT', '/user/TaskCount', 84, 11, 1, 1, 16, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (852, 852, 'L_GLOBAL_MODEL_MESSAGE', '/user/MessageSettings/', 84, 12, 1, 0, 6, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (853, 853, 'L_MENU_ADMIN_NOTIFICATION_SETTINGS', '/user/notifsettings/', 84, 13, 1, 1, 6, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (854, 854, 'L_MENU_MAIL_SMS_TEST', '/user/mailtest', 84, 14, 1, 1, 6, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (855, 855, 'L_MENU_ADRESSBOOK_SETTINGS', '/user/setcontact', 84, 15, 1, 0, 6, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (856, 856, 'L_GLOBAL_WORK_CALENDAR', '/user/WorkCalendar/', 84, 16, 1, 1, 6, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (857, 857, 'L_MENU_ADMIN_DICTIONARY', '/user/admindict/', 84, 17, 1, 1, 21, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (858, 858, 'L_GLOBAL_PLUGINS', '/user/plugins', 84, 18, 1, 1, 6, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (859, 859, 'L_SEARCH_ADMIN', '/java/searchAdminPage', 84, 19, 1, 1, 6, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (860, 860, 'L_MENU_SISTEM_INFORMATION', '/user/sisteminfo', 84, 20, 1, 1, 6, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (861, 861, 'L_AU_DOC_CARDS', '/user/DocRegisterCards', 86, 1, 1, 1, 4, 0, 'docflow');
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (862, 862, 'L_MENU_ROUTESCHEME_EDITOR', '/user/rseditor', 86, 2, 1, 1, 4, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (863, 863, 'L_AU_DOCUMENT_COUNTERS', '/user/DocCount', 86, 3, 1, 1, 4, 0, 'docflow');
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (864, 864, 'L_GLOBAL_DICTIONARY_EDITOR', '/user/diction', 86, 4, 1, 1, 4, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (871, 871, 'L_GLOBAL_USE_STATISTIC', '/user/report_usestatistic', 87, 1, 1, 1, 5, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (872, 872, 'L_MENU_TRUST_POLICY', '/user/hostzones/', 87, 2, 1, 1, 5, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (873, 873, 'L_MENU_SECURITYREP5', '/user/securityrep5/', 87, 3, 1, 1, 5, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (874, 874, 'L_MENU_SECURITYREP4', '/user/securityrep4/', 87, 4, 1, 1, 5, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (875, 875, 'L_MENU_SECURITYREP3', '/user/securityrep3/', 87, 5, 1, 1, 5, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (876, 876, 'L_MENU_SECURITYREP2', '/user/securityrep2/', 87, 6, 1, 1, 5, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (877, 877, 'L_MENU_SECURITYREP1', '/user/securityrep1/', 87, 7, 1, 1, 5, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (878, 878, 'L_AU_LOG_TASKACCESSFORBIDDEN', '/user/prereport_selusers/taskaccessforbidden', 87, 8, 1, 1, 5, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (879, 879, 'L_MENU_SECURITYREP6', '/user/securityrep6/', 87, 9, 1, 0, 5, 0, 'docflow');
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (880, 880, 'L_MENU_DELETEDOCUMENTREPORT', '/user/selectdocumentprereport/deleted_documents/', 87, 10, 1, 1, 0, 0, 'docflow');
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (881, 881, 'L_MENU_REPORT_OUTERS_IN_LICENSE', '/user/prereport_outerusers', 87, 11, 1, 1, 6, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (882, 882, 'L_MENU_MYOPTIONS', '/user/pwd/', 88, 1, 1, 1, 0, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (883, 883, 'L_GLOBAL_MOTIWOPTIONS', '/user/pwd_settings/', 88, 2, 1, 1, 0, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (884, 884, 'L_MENU_MAILBOX_OPTIONS', '/user/mailboxoptions', 88, 3, 1, 1, 0, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (885, 885, 'L_MENU_MENUSETTINGS', '/user/menuedit/', 88, 4, 2, 1, 0, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (886, 886, 'L_MENU_SHADOWS', '/user/op_shadow/', 88, 5, 1, 1, 8, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (887, 887, 'L_MENU_NOTIFICATION_SETTINGS', '/user/pwd_notifprefs/', 88, 6, 1, 1, 0, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (888, 888, 'L_GLOBAL_COLOR_SETTINGS', '/user/pwd_colorprefs/', 88, 7, 1, 1, 0, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (889, 889, 'L_OPTIONS_DOCPREFS3', '/user/pwd_docprefs/', 88, 8, 1, 1, 0, 0, 'docflow');
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (890, 890, 'L_MENU_MYTEMPLATES', '/user/templateactions/', 88, 9, 1, 1, 0, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (891, 891, 'L_GLOBAL_EMAIL_EMPLOYER_GROUPS', '/user/outer_user_group_list', 88, 10, 1, 1, 0, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (892, 892, 'L_MENU_OUTER_USERS_EDIT', '/user/edit_outer_user/', 88, 11, 1, 1, 0, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (893, 893, 'L_MENU_TASK_TEMPLATES', '/user/tasktemplates', 88, 12, 1, 1, 0, 0, 'workflow');
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (894, 894, 'IWG_TEMPLATE', '/user/iwgtemplate', 88, 13, 1, 1, 0, 0, 'workflow');
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (895, 895, 'L_CHECKPOINTS_TEMPLATES', '/user/checkpoints_templates', 88, 14, 1, 1, 0, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (896, 896, 'L_MENU_DOCUMENTTEMPLATES', '/documents/documenttemplate', 88, 15, 1, 1, 1, 0, 'docflow');
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (951, 951, 'L_GENERAL_SEARCH', '/java/javasearch/', 95, 1, 1, 1, 0, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (952, 952, 'L_GLOBAL_TASK_SEARCH', '/user/searchtask', 95, 2, 1, 1, 0, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (953, 953, 'L_SEARCH_BY_TASK_NAME', '/user/searchbynum', 95, 3, 1, 1, 0, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (954, 954, 'L_SEARCHING_DOCUMENTS', '/documents/search/', 95, 4, 1, 1, 0, 0, 'docflow');
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (955, 955, 'L_SEARCH_BY_NOMER_DOCUMENT', '/user/searchdocbynum', 95, 5, 1, 1, 0, 0, 'docflow');
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (956, 956, 'L_SEARCH_BY_MES_NUM', '/user/searchbymesnum/', 95, 6, 1, 1, 0, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (501, 501, 'L_MENU_NEW_MESSAGE_ADD', '/user/unionsend/first', 50, 2, 1, 1, 0, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (502, 502, 'L_MENU_MESSAGE_ADD', '/user/noticeedit', 50, 3, 1, 1, 6, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (503, 503, 'L_MENU_UIONSENDEDIT', '/user/notices/', 50, 1, 1, 1, 0, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (901, 901, 'L_MENU_MANUAL', '/user/manuals', 90, 1, 1, 1, 0, 0, NULL);
- INSERT INTO MENUITEMS (ID, ITEM_ID, DMESS_TAGNAME, URL, IDPARENT, NUMBER, ISVISIBLE, ISDEFVISIBLE, RIGHT_KIND, ID_EMPLOYER, EDITION) VALUES (902, 902, 'L_QUESTIONS_AND_ANSWERS', '/FAQ/index.phtml', 90, 2, 1, 1, 0, 0, NULL);
- --копируем в пользователя -1
- execute procedure copymenuitems (-1);
- --копируем во всех неудаленных пользователей
- for select e.id
- from employer e
- where e.isdeleted = 0
- into :VAR_EMP
- do
- begin
- execute procedure copymenuitems (:VAR_EMP);
- end
- end^
- SET TERM ; ^
- commit;
- EXECUTE PROCEDURE MENUTRESH;
- commit;
- DROP PROCEDURE MENUTRESH;
- commit;
- update menuitems m set m.url = '/motiw4/Motiw4/Motiw4.html?sessionover=1' where m.dmess_tagname = 'L_MENU_IAP_ADMINISTRATION';
- commit;
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE GET_FURIGHT_EMP_BY_DEP (
- i_empid integer,
- i_depid integer,
- i_only_this_dep smallint)
- returns (
- o_empid integer)
- as
- declare variable l_flag smallint;
- declare variable l_depid integer;
- begin
- /*возвращает людей, на которых есть ПОЛНЫЕ ПРАВА по подразделениям (с/без вложенных)*/
- if (I_ONLY_THIS_DEP = 1) then
- begin
- for select id from employer e
- join permission p on ( p.id_boss = :i_empid
- and p.enabled = 1
- and e.id = p.id_employer)
- where e.id_department = :I_DEPID and
- e.isdeleted = 0
- into :O_EMPID
- do
- suspend;
- end
- else
- for select gt.o_id from gettree (:I_DEPID, 0) gt
- join deppermission dp on ( dp.id_department = gt.o_id
- and id_employer = :i_empid
- and enabled = 1 )
- INTO :L_DEPID
- do
- begin
- begin
- for select id from employer e
- join permission p on ( p.id_boss = :i_empid
- and p.enabled = 1
- and e.id = p.id_employer)
- where e.id_department = :L_DEPID and
- e.isdeleted = 0
- into :O_EMPID
- do
- suspend;
- end
- end
- END^
- SET TERM ; ^
- commit;
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE GETDOCUMENTS_REGISTRY (
- i_id_employer integer,
- i_id_department integer,
- i_id_doctype integer,
- i_only_thisdep smallint,
- i_from_date timestamp,
- i_to_date timestamp)
- returns (
- o_id_document integer,
- o_createdate timestamp,
- o_regdate timestamp,
- o_state smallint,
- o_taskid integer,
- o_doc_version integer,
- o_document_files varchar(30000))
- as
- declare variable l_rootdepid integer;
- begin
- /*возвращает идшники для расширеного реестра документов и еще всякую инфу*/
- if (i_id_department is null) then
- select id_department from employer where id = :i_id_employer
- into :l_rootdepid;
- else
- l_rootdepid = :i_id_department;
- begin
- for select distinct d.id, (select first 1 g.id_task
- from grouptask g
- where g.task_id_document = d.id
- and g.id_employer in
- (select o_empid
- from GET_FURIGHT_EMP_BY_DEP ( :i_id_employer , :l_rootdepid , :i_only_thisdep ) )
- and g.task_id_document <>0
- and g.task_state = 0)
- from documents d
- where d.isdeleted=0
- and d.regdate >= :i_from_date
- and d.regdate <= :i_to_date
- and d.id_doctype = :I_ID_DOCTYPE
- into :o_id_document,
- :o_taskid
- do
- begin
- select
- d.createdate,
- d.regdate,
- d.state,
- d.doc_version
- from documents d
- where d.id=:o_id_document
- into
- :o_createdate,
- :o_regdate,
- :o_state,
- :o_doc_version;
- select o_document_files from get_doc_files_list(:o_id_document,0)
- into :o_document_files;
- suspend;
- end
- end
- END^
- SET TERM ; ^
- commit;
- commit;
- commit work;
- Use CONNECT or CREATE DATABASE to specify a database
- CONNECT "/var/Motiw/db/motiw.fdb" USER 'SYSDBA' PASSWORD 'masterkey';
- SET NAMES WIN1251;
- /*-------------------------------------------------------------------------------------------------------------------------------------------------------------*/
- /* Даем существующим пользователям право на тип задачи "Обычный" */
- /*-------------------------------------------------------------------------------------------------------------------------------------------------------------*/
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE TMP_SET_RIGHT_ON_USUAL
- AS
- declare variable l_id_employer integer;
- BEGIN
- FOR SELECT
- id
- FROM
- employer
- INTO
- :l_id_employer
- DO
- BEGIN
- EXECUTE PROCEDURE SET_RIGHT_EMPLOYER(:l_id_employer, 15, 0, 1);
- END
- END ^
- SET TERM ; ^
- commit;
- EXECUTE PROCEDURE TMP_SET_RIGHT_ON_USUAL;
- commit;
- DROP PROCEDURE TMP_SET_RIGHT_ON_USUAL;
- commit;
- /*-------------------------------------------------------------------------------------------------------------------------------------------------------------*/
- /* Конвертация контрольных точек в подзадачи (начало) */
- /*-------------------------------------------------------------------------------------------------------------------------------------------------------------*/
- SET TERM ^ ;
- CREATE OR ALTER TRIGGER TASK_BI2 FOR TASK
- ACTIVE BEFORE INSERT POSITION 2
- AS
- BEGIN
- IF (NEW.ID IS NULL) THEN
- NEW.ID = GEN_ID(GEN_TASK, 1);
- IF (NEW.NUMERATOR IS NULL) THEN
- NEW.NUMERATOR = NEW.ID;
- END ^
- SET TERM ; ^
- commit;
- EXECUTE PROCEDURE ADD_FIELD_IF_DOES_NOT_EXIST('TASK', 'TMP_ID_CHECKPOINT', 'INTEGER');
- RESULT
- =======
- 1
- commit;
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE TMP_DROP
- AS
- declare variable is_exist smallint;
- BEGIN
- SELECT result FROM IS_TRIGGER_EXISTS('TASK_BI2')
- INTO :is_exist;
- IF (is_exist = 1) THEN
- begin
- EXECUTE STATEMENT
- 'DROP TRIGGER TASK_BI2;';
- end
- SELECT result FROM IS_FIELD_EXISTS('TASK', 'TMP_ID_CHECKPOINT')
- INTO :is_exist;
- IF (is_exist = 1) THEN
- begin
- EXECUTE STATEMENT
- 'ALTER TABLE TASK DROP TMP_ID_CHECKPOINT;';
- end
- SELECT result FROM IS_TABLE_EXISTS('CHECKPOINTS')
- INTO :is_exist;
- IF (is_exist = 1) THEN
- begin
- EXECUTE STATEMENT
- 'DROP GENERATOR GEN_CHECKPOINTS_ID;';
- EXECUTE STATEMENT
- 'DROP TRIGGER CHECKPOINTS_AU0;';
- EXECUTE STATEMENT
- 'DROP TRIGGER CHECKPOINTS_BU0;';
- EXECUTE STATEMENT
- 'DROP TRIGGER CHECKPOINTS_BI;';
- EXECUTE STATEMENT
- 'DROP TRIGGER CHECKPOINTS_BD0;';
- EXECUTE STATEMENT
- 'DROP TABLE CHECKPOINTS;';
- end
- END ^
- SET TERM ; ^
- commit;
- EXECUTE PROCEDURE ADD_FIELD_IF_DOES_NOT_EXIST('TASK', 'IS_CHECKPOINT', 'SMALLINT');
- RESULT
- =======
- 1
- commit;
- EXECUTE PROCEDURE ADD_INDEX_IF_DOES_NOT_EXIST('NOTICE_IDX_ID_OBJ', 'NOTICE', 'ID_OBJ');
- RESULT
- =======
- 1
- commit;
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE TMP_CHECKPOINTS_2_SUBTASKS
- AS
- BEGIN
- INSERT INTO task (name,
- startdate,
- enddate,
- iswithreport,
- state,
- priority,
- description,
- id_project,
- send_actions,
- parentid,
- id_realauthor,
- id_taskinitiator,
- tsreport,
- id_meta_dictionary,
- id_department,
- tmp_id_checkpoint,
- is_checkpoint)
- SELECT
- chp.name,
- chp.enddate,
- chp.enddate,
- 0,
- chp.state,
- 0,
- chp.description,
- (SELECT t1.id_project FROM task t1 WHERE t1.id = chp.id_task),
- 1,
- chp.id_task,
- (SELECT t1.id_realauthor FROM task t1 WHERE t1.id = chp.id_task),
- (SELECT t1.id_taskinitiator FROM task t1 WHERE t1.id = chp.id_task),
- chp.readydate,
- 0,
- (SELECT t1.id_department FROM task t1 WHERE t1.id = chp.id_task),
- chp.id,
- 1
- FROM checkpoints chp;
- UPDATE notice n
- SET n.id_obj = (SELECT t.id FROM task t
- WHERE t.tmp_id_checkpoint = n.id_obj)
- WHERE n.noticetype = 5;
- END ^
- SET TERM ; ^
- commit;
- EXECUTE PROCEDURE TMP_CHECKPOINTS_2_SUBTASKS;
- commit;
- DROP PROCEDURE TMP_CHECKPOINTS_2_SUBTASKS;
- commit;
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE CALENDARREPORT (
- i_employer_id integer)
- returns (
- o_projectname varchar(2000),
- o_proj_id integer,
- o_taskid integer,
- o_taskname varchar(2000),
- o_startdate timestamp,
- o_enddate timestamp,
- o_isreported smallint,
- o_isrejected smallint,
- o_isgroup smallint,
- o_isviewed smallint,
- o_adate timestamp,
- o_documentid integer,
- o_ishidden smallint,
- o_istrashproject smallint,
- o_isnewactions smallint,
- o_pdocumentid integer,
- o_taskcolor smallint,
- o_doctypename varchar(200),
- o_why_task_there smallint,
- o_entity_end_date timestamp,
- o_id_entity integer,
- o_entity_text varchar(2000))
- as
- declare variable l_originalid integer;
- declare variable l_taskexist_result smallint;
- begin
- select e.parentid
- from employer e
- where e.id=:i_employer_id
- into :L_ORIGINALID;
- if (:L_ORIGINALID is null) then
- L_ORIGINALID=:i_employer_id;
- for select t.id, 1, t.enddate
- from task t
- join grouptask gt on t.id = gt.id_task
- where t.state = 0 and
- t.isdeleted = 0 and
- gt.id_original = :i_employer_id and
- (gt.is_author = 1 or gt.is_respperson = 1 or
- gt.is_worker = 1 or gt.is_shadow = 1)
- into :o_taskid,:o_why_task_there,:o_entity_end_date
- DO
- BEGIN
- select o_id,
- O_PROJECTNAME,
- O_TASKNAME,
- O_STARTDATE,
- O_ENDDATE,
- O_ISREPORTED,
- O_ISREJECTED,
- O_PROJ_ID,
- O_ISGROUP,
- O_ISVIEWED,
- O_ADATE,
- O_DOCUMENTID,
- O_ISHIDDEN,
- O_ISTRASHPROJECT,
- O_ISNEWACTIONS,
- O_PDOCUMENTID,
- O_TASKCOLOR,
- O_DOCTYPENAME,
- O_MAIN_RESULT
- from gettaskattributes_for_calendar(:O_TASKID, :L_ORIGINALID)
- into :o_taskid,
- :O_PROJECTNAME,
- :O_TASKNAME,
- :O_STARTDATE,
- :O_ENDDATE,
- :O_ISREPORTED,
- :O_ISREJECTED,
- :O_PROJ_ID,
- :O_ISGROUP,
- :O_ISVIEWED,
- :O_ADATE,
- :O_DOCUMENTID,
- :O_ISHIDDEN,
- :O_ISTRASHPROJECT,
- :O_ISNEWACTIONS,
- :O_PDOCUMENTID,
- :O_TASKCOLOR,
- :O_DOCTYPENAME,
- :L_TASKEXIST_RESULT;
- if (:L_TASKEXIST_RESULT=1) then
- begin
- o_entity_text=null;o_id_entity=null;
- suspend;
- if (O_ISHIDDEN=1) then
- begin
- /* for SELECT 2,ht.showdate
- FROM hiddentasks ht
- WHERE ht.id_task=:o_taskid and ht.id_employer=:l_originalid
- INTO :O_WHY_TASK_THERE,:o_entity_end_date
- do suspend;
- */
- for select 2,gt.show_task_date
- FROM grouptask gt
- WHERE gt.id_task=:o_taskid and gt.id_original=:l_originalid
- INTO :O_WHY_TASK_THERE,:o_entity_end_date
- do suspend;
- end
- for SELECT 4, cp.enddate, cp.description, cp.id
- FROM task cp
- WHERE cp.is_checkpoint = 1 and cp.parentid = :o_taskid and cp.state = 0
- INTO :O_WHY_TASK_THERE,:o_entity_end_date,:o_entity_text,:o_id_entity
- do suspend;
- end
- END
- if (:L_ORIGINALID = :i_employer_id) then
- begin
- FOR SELECT n1.id_task,3,n1.meetingtime,n1.name||'{L_SENDMR_PLACE}'||n1.place||'{L_GLOBAL_ADDINFO}'||n1.description,n1.id
- FROM notice n1,
- noticeview nv,
- task t3
- WHERE nv.id_employer = :i_employer_id and
- nv.id_notice=n1.id and
- n1.isdeleted=0 and
- n1.id_task=t3.id and
- t3.state = 0 and
- t3.isdeleted = 0 and
- n1.noticetype=3
- INTO :O_TASKID,:O_WHY_TASK_THERE,:o_entity_end_date,:o_entity_text,:o_id_entity
- DO
- BEGIN
- select o_id,
- O_PROJECTNAME,
- O_TASKNAME,
- O_STARTDATE,
- O_ENDDATE,
- O_ISREPORTED,
- O_ISREJECTED,
- O_PROJ_ID,
- O_ISGROUP,
- O_ISVIEWED,
- O_ADATE,
- O_DOCUMENTID,
- O_ISHIDDEN,
- O_ISTRASHPROJECT,
- O_ISNEWACTIONS,
- O_PDOCUMENTID,
- O_TASKCOLOR,
- O_DOCTYPENAME,
- O_MAIN_RESULT
- from gettaskattributes_for_calendar(:O_TASKID, :L_ORIGINALID)
- into :o_taskid,
- :O_PROJECTNAME,
- :O_TASKNAME,
- :O_STARTDATE,
- :O_ENDDATE,
- :O_ISREPORTED,
- :O_ISREJECTED,
- :O_PROJ_ID,
- :O_ISGROUP,
- :O_ISVIEWED,
- :O_ADATE,
- :O_DOCUMENTID,
- :O_ISHIDDEN,
- :O_ISTRASHPROJECT,
- :O_ISNEWACTIONS,
- :O_PDOCUMENTID,
- :O_TASKCOLOR,
- :O_DOCTYPENAME,
- :L_TASKEXIST_RESULT;
- if (:L_TASKEXIST_RESULT=1) then suspend;
- END
- FOR SELECT n1.id_task,5,nv.showdate,n1.name||'{L_GLOBAL_ADDINFO}'||n1.description,n1.id
- FROM notice n1,
- noticeview nv,
- task t3
- WHERE nv.id_employer = :i_employer_id and
- nv.id_notice=n1.id and
- n1.isdeleted=0 and
- n1.id_task=t3.id and
- t3.state = 0 and
- t3.isdeleted = 0 and
- n1.noticetype=6 and
- n1.isshowtasklink=1
- INTO :O_TASKID,:O_WHY_TASK_THERE,:o_entity_end_date,:o_entity_text,:o_id_entity
- DO
- BEGIN
- select o_id,
- O_PROJECTNAME,
- O_TASKNAME,
- O_STARTDATE,
- O_ENDDATE,
- O_ISREPORTED,
- O_ISREJECTED,
- O_PROJ_ID,
- O_ISGROUP,
- O_ISVIEWED,
- O_ADATE,
- O_DOCUMENTID,
- O_ISHIDDEN,
- O_ISTRASHPROJECT,
- O_ISNEWACTIONS,
- O_PDOCUMENTID,
- O_TASKCOLOR,
- O_DOCTYPENAME,
- O_MAIN_RESULT
- from gettaskattributes_for_calendar(:O_TASKID, :L_ORIGINALID)
- into :o_taskid,
- :O_PROJECTNAME,
- :O_TASKNAME,
- :O_STARTDATE,
- :O_ENDDATE,
- :O_ISREPORTED,
- :O_ISREJECTED,
- :O_PROJ_ID,
- :O_ISGROUP,
- :O_ISVIEWED,
- :O_ADATE,
- :O_DOCUMENTID,
- :O_ISHIDDEN,
- :O_ISTRASHPROJECT,
- :O_ISNEWACTIONS,
- :O_PDOCUMENTID,
- :O_TASKCOLOR,
- :O_DOCTYPENAME,
- :L_TASKEXIST_RESULT;
- if (:L_TASKEXIST_RESULT=1) then suspend;
- END
- end
- end^
- SET TERM ; ^
- commit;
- /* Переносим триггеры из checkpoints в task*/
- SET TERM ^ ;
- CREATE OR ALTER TRIGGER TASK_AU01 FOR TASK
- ACTIVE AFTER UPDATE POSITION 0
- AS
- begin
- if (new.parentid > 0) then
- begin
- if (old.state = 0 and new.state = 1) then
- begin
- update notice n set n.isdeleted = 1
- where n.noticetype = 5 and n.obj_kind = 1 and n.id_obj = old.id and n.id_task = old.parentid;
- delete from noticeview nv
- where nv.id_notice in (select n.id from notice n
- where n.noticetype = 5 and n.obj_kind = 1 and n.id_obj = old.id and n.id_task = old.parentid and n.isdeleted = 1);
- end
- else
- if (old.enddate <> new.enddate) then
- begin
- update notice n set n.showdate = n.showdate + (new.enddate - old.enddate)
- where n.noticetype = 5 and n.obj_kind = 1 and n.id_obj = old.id and n.id_task = old.parentid and n.isdeleted = 0;
- update noticeview nv set nv.showdate = nv.showdate + (new.enddate - old.enddate)
- where nv.id_notice in (select n.id from notice n
- where n.noticetype = 5 and n.obj_kind = 1 and n.id_obj = old.id and n.id_task = old.parentid and n.isdeleted = 0);
- end
- end
- end^
- SET TERM ; ^
- commit;
- SET TERM ^ ;
- CREATE OR ALTER TRIGGER TASK_AD0 FOR TASK
- ACTIVE AFTER DELETE POSITION 0
- AS
- DECLARE VARIABLE L_N_ID INTEGER;
- begin
- for select n.id
- from notice n
- where n.noticetype=5 and
- n.obj_kind=1 and
- n.id_obj=old.id and
- n.id_task=old.parentid
- into :L_N_ID
- do
- begin
- delete from noticeview nv where nv.id_notice=:L_N_ID;
- delete from notice n2 where n2.id=:L_N_ID;
- end
- end^
- SET TERM ; ^
- commit;
- EXECUTE PROCEDURE TMP_DROP;
- Statement failed, SQLCODE = -607
- unsuccessful metadata update
- -Trigger CHECKPOINTS_BU0 not found
- -At procedure 'TMP_DROP' line: 32, col: 13
- After line 888 in file /tmp/patch_db/script
- DROP PROCEDURE TMP_DROP;
- commit;
- /*-------------------------------------------------------------------------------------------------------------------------------------------------------------*/
- /* Конвертация контрольных точек в подзадачи (окончание) */
- /*-------------------------------------------------------------------------------------------------------------------------------------------------------------*/
- /*-------------------------------------------------------------------------------------------------------------------------------------------------------------*/
- /* Позволяем Ответственному Руководителю редактировать задачу */
- /*-------------------------------------------------------------------------------------------------------------------------------------------------------------*/
- SET TERM ^ ;
- ALTER PROCEDURE CHECKTASKEDIT (
- I_ID_EMPLOYER Integer,
- I_ID_TASK Integer )
- RETURNS (
- O_RESULT Smallint )
- AS
- DECLARE VARIABLE L_SUPERVISOR SMALLINT;
- DECLARE VARIABLE L_AUTHOR_ID INTEGER;
- DECLARE VARIABLE L_COUNT INTEGER;
- begin
- /* Проверяет может ли пользователь редактировать аттрибуты задачи. Это название, описание, приоритет и т. п.
- * В общем все то, что редактируется при заходе в задачу, в шапке задачи маленькими картиночками справа.
- * Редактировать может либо автор, либо администратор системы, а теперь и ответственный руководитель.
- */
- /* Проверяем автора или ответственного руководителя */
- if (exists(select gt.id_task
- from grouptask gt
- where gt.id_task = :I_ID_TASK and
- gt.id_original = :I_ID_EMPLOYER and
- (gt.is_author = 1 or gt.is_respperson = 1))) then
- begin
- o_result = 1;
- suspend;
- exit;
- end
- /* Проверяем не администратор ли системы */
- select o_result
- from get_right_employer_and_group(:i_id_employer,6,0)
- into :l_supervisor;
- if (l_supervisor > 0) then
- begin
- o_result = 1;
- suspend;
- exit;
- end
- o_result = 0;
- suspend;
- end^
- SET TERM ; ^
- commit;
- GRANT EXECUTE
- ON PROCEDURE CHECKTASKEDIT TO ROLE COMMON;
- GRANT EXECUTE
- ON PROCEDURE CHECKTASKEDIT TO TRIGGER DEPARTMENT_BU0;
- GRANT EXECUTE
- ON PROCEDURE CHECKTASKEDIT TO TRIGGER EMPLOYER_AI0;
- GRANT EXECUTE
- ON PROCEDURE CHECKTASKEDIT TO TRIGGER EMPLOYER_AU0;
- GRANT EXECUTE
- ON PROCEDURE CHECKTASKEDIT TO TRIGGER GROUPTASK_AD0;
- GRANT EXECUTE
- ON PROCEDURE CHECKTASKEDIT TO TRIGGER GROUPTASK_AI0;
- GRANT EXECUTE
- ON PROCEDURE CHECKTASKEDIT TO SYSDBA;
- GRANT EXECUTE
- ON PROCEDURE CHECKTASKEDIT TO TRIGGER TASK_AU0;
- commit;
- /*-------------------------------------------------------------------------------------------------------------------------------------------------------------*/
- /* Позволяем Ответственному Руководителю редактировать задачу (окончание) */
- /*-------------------------------------------------------------------------------------------------------------------------------------------------------------*/
- /*-------------------------------------------------------------------------------------------------------------------------------------------------------------*/
- /* Переиндексация */
- /*-------------------------------------------------------------------------------------------------------------------------------------------------------------*/
- /* reindexTasks */
- DELETE FROM queue_indexing WHERE object_kind = 2;
- INSERT INTO queue_indexing(id_object, object_kind, event_code) SELECT t.id, 2, 1 FROM task t WHERE t.isdeleted = 0;
- /* reindexActions */
- DELETE FROM queue_indexing WHERE object_kind = 1;
- INSERT INTO queue_indexing(id_object, object_kind, event_code) SELECT a.id, 1, 1 FROM actions a JOIN task t ON a.id_task = t.id WHERE t.isdeleted = 0;
- /* reindexDocuments */
- DELETE FROM queue_indexing WHERE object_kind = 3;
- INSERT INTO queue_indexing(id_object, object_kind, event_code) SELECT d.id, 3, 1 FROM documents d WHERE d.isdeleted = 0;
- /* reindexTaskFiles */
- DELETE FROM queue_indexing WHERE object_kind = 5;
- INSERT INTO queue_indexing(id_object, object_kind, event_code) SELECT att.id, 5, 1 FROM attachment att WHERE att.isdeleted = 0;
- /* reindexDocumentFiles */
- DELETE FROM queue_indexing WHERE object_kind = 7;
- INSERT INTO queue_indexing(id_object, object_kind, event_code) SELECT da.id, 7, 1 FROM documentattachment da WHERE da.isdeleted = 0;
- /* reindexDocumentLibrary */
- DELETE FROM queue_indexing WHERE object_kind = 9;
- INSERT INTO queue_indexing(id_object, object_kind, event_code) SELECT dlf.id, 9, 1 FROM dlfile dlf WHERE dlf.isdeleted = 0;
- /* reindexEmployers */
- DELETE FROM queue_indexing WHERE object_kind = 10;
- INSERT INTO queue_indexing(id_object, object_kind, event_code) SELECT e.id, 10, 1 FROM employer e WHERE e.isdeleted = 0;
- /* reindexContacts */
- DELETE FROM queue_indexing WHERE object_kind = 11;
- INSERT INTO queue_indexing(id_object, object_kind, event_code)
- SELECT distinct mv.id_record, 11, 1
- FROM meta_dictionary md
- JOIN meta_field mf ON md.id = mf.id_md
- JOIN meta_value mv ON mf.id = mv.id_mf
- WHERE (md.issystem = 2 and md.isdeleted = 0 and mv.isdeleted = 0);
- /* reindexProjects */
- DELETE FROM queue_indexing WHERE object_kind = 12;
- INSERT INTO queue_indexing(id_object, object_kind, event_code) SELECT distinct ID, 12, 1 FROM PROJECT;
- commit;
- /*-------------------------------------------------------------------------------------------------------------------------------------------------------------*/
- /* Для полей-ссылок заполняем value_varchar отображаемым значением */
- /*-------------------------------------------------------------------------------------------------------------------------------------------------------------*/
- UPDATE
- meta_value mv
- SET
- mv.value_varchar = (SELECT FIRST 1
- CASE
- WHEN mf2.id_type_field in (1, 7, 10, 11, 12, 13) THEN mv1.value_char
- WHEN mf2.id_type_field = 5 THEN mv1.value_date
- WHEN mf2.id_type_field = 4 THEN mv1.value_float
- WHEN mf2.id_type_field in (3, 6, 14, 16, 17) THEN mv1.value_integer
- WHEN mf2.id_type_field in (2, 8, 9, 18) THEN mv1.value_varchar
- ELSE null
- END
- FROM
- meta_value mv1
- JOIN
- meta_field mf1 ON mf1.id = mv.id_mf
- JOIN
- meta_field mf2 ON mf2.id = mf1.id_connect
- WHERE
- mv1.id_record = mv.value_integer AND
- mv1.id_mf = mf1.id_connect AND
- mv1.isdeleted = 0)
- WHERE
- mv.isdeleted = 0 AND
- mv.id_mf in (SELECT
- mf.id
- FROM
- meta_field mf
- WHERE
- mf.id_type_field in (8, 9) AND
- mf.isdeleted = 0
- );
- commit;
- /*stasy - избавляемся от "избранного"*/
- /*сначала заменим во всех процедурах где исспользуется*/
- /*GETALLTASKRIGHTS*/
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE GETALLTASKRIGHTS (
- i_myid integer,
- i_taskid integer)
- returns (
- o_isrights smallint,
- o_isgroup smallint,
- o_isauthor smallint,
- o_isemployer smallint,
- o_isclosed smallint,
- o_isonlyforview smallint,
- o_parentid integer,
- o_documentid integer,
- o_pdocumentid integer,
- o_isreported smallint,
- o_isdeleted integer,
- o_isingroup smallint,
- o_isinsignlist smallint,
- o_taskexamined smallint,
- o_taskfolderid integer,
- o_recive_sms smallint,
- o_recive_mail smallint,
- o_taskid integer,
- o_iscontroller smallint)
- as
- begin
- /* Параметр O_TASKID нужен для проверки того, что проца действительно вернула данные, а не отвалилась
- Для режима высокой нагрузки.
- */
- O_TASKID = 0;
- execute procedure checkrightsfortask(:i_myid,:i_taskid)
- returning_values :o_isrights;
- select t.state,
- t.isreported,
- t.isgroup,
- t.isonlyforview,
- t.parentid,
- t.id_document,
- t.isdeleted,
- t.id_document_exec
- from task t
- where t.id=:i_taskid
- into :o_isclosed,
- :o_isreported,
- :o_isgroup,
- :o_isonlyforview,
- :o_parentid,
- :o_documentid,
- :o_isdeleted,
- :o_pdocumentid;
- if (exists (select id_employer
- from grouptask gt
- where gt.id_original=:i_myid and
- gt.id_task=:i_taskid and
- gt.is_author=1) ) then o_isauthor=1;
- else o_isauthor=0;
- if (exists (select id_employer
- from grouptask gt
- where gt.id_original=:i_myid and
- gt.id_task=:i_taskid and
- gt.is_respperson=1) ) then o_isemployer=1;
- else o_isemployer=0;
- o_isingroup=0;
- if (o_isgroup=1) then /*Проверяем находится ли емплоер в группе*/
- begin
- if (exists (select gt.id_employer
- from grouptask gt
- where gt.id_task=:i_taskid and
- gt.id_original=:i_myid and
- (gt.is_worker=1 or gt.is_shadow=1))) then
- o_isingroup=1;
- end
- o_iscontroller=0;
- if (exists (select gt.id_employer
- from grouptask gt
- where gt.id_task=:i_taskid and
- gt.id_original=:i_myid and
- (gt.is_controler=1))) then
- o_iscontroller=1;
- o_isinsignlist = 0;
- if (o_documentid>0) then
- begin
- if (exists(select rn.id_employer from routetrees rt
- join routenode rn on rt.id = rn.id_routetree
- where (rt.id_task = :i_taskid)and(rt.isdeleted=0)and
- (rn.id_employer = :i_myid)and(rn.isdeleted=0)
- )) then
- o_isinsignlist = 1;
- else
- if (exists(select rn.id_employer from routetrees rt
- join routenode rn on rt.id = rn.id_routetree
- join getemployeraliases(:i_myid) gea on gea.o_employerid = rn.id_employer
- where (rt.id_task = :i_taskid)and(rt.isdeleted=0)and(rn.isdeleted=0)
- )) then
- o_isinsignlist = 1;
- end
- o_taskexamined=0;
- if (o_isonlyforview=1) then
- begin
- if (exists(select id
- from actions
- where id_employer = :i_myid and
- id_task = :i_taskid and
- examinated is not null and
- examinated > 0
- )
- ) then
- o_taskexamined=1;
- end
- if (:o_taskfolderid is null) then
- o_taskfolderid=0;
- select gtms.o_recive_sms,
- gtms.o_recive_mail
- from get_task_mail_sms(:i_taskid,:i_myid) gtms
- into :o_recive_sms,
- :o_recive_mail;
- O_TASKID = :i_taskid;
- suspend;
- end^
- SET TERM ; ^
- commit;
- /*GET_TASK_ATTRIBUTES_AS_NUM*/
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE GET_TASK_ATTRIBUTES_AS_NUM (
- i_id_task integer,
- i_id_employer integer)
- returns (
- o_value smallint)
- as
- declare variable l_priority smallint;
- declare variable l_is_secret smallint;
- declare variable l_is_olnly_for_view smallint;
- declare variable l_enddate timestamp;
- begin
- /*
- 1 - Скрытая задача
- 2 - В избранном
- 3 - Важная
- 5 - Для ознакомления
- 6 - Просроченная
- 7 - Секретная
- 8- обычная задача
- */
- o_value=8;
- if (exists(select ht.id_task from hiddentasks ht
- where ht.id_employer=:i_id_employer and ht.id_task=:i_id_task)) then
- begin
- o_value=1;
- suspend;
- end
- select t.priority,t.issecret,t.isonlyforview,t.enddate from task t
- where t.id = :i_id_task
- into :l_priority,:l_is_secret,:l_is_olnly_for_view,:l_enddate;
- if (:l_priority=1) then
- begin
- o_value=3;
- suspend;
- end
- if (:l_is_olnly_for_view=1) then
- begin
- o_value=5;
- suspend;
- end
- if ((:l_enddate<current_timestamp)) then
- begin
- o_value=6;
- suspend;
- end
- if (:l_is_secret=1) then
- begin
- o_value=7;
- suspend;
- end
- if (:o_value=8) then suspend;
- end^
- SET TERM ; ^
- commit;
- /*GET_TASK_USERS_TO_NOTIFY*/
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE GET_TASK_USERS_TO_NOTIFY (
- i_task_id integer,
- isonlyforview smallint,
- id_document integer)
- returns (
- o_id_employer integer,
- o_status integer)
- as
- declare variable l_emp_id integer;
- declare variable l_res1 smallint;
- declare variable l_res2 smallint;
- begin
- for select gt.id_original as eid,0
- from grouptask gt
- where gt.id_task = :i_task_id and
- (gt.is_author = 1 or gt.is_respperson = 1 or gt.is_worker = 1 or gt.is_controler=1 or gt.is_shadow=1 ) and
- gt.is_show_task = 1
- into :O_ID_EMPLOYER,:o_status
- do
- suspend;
- end^
- SET TERM ; ^
- commit;
- /*INFORMER2_CHECKRIGHTSFORTASK*/
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE INFORMER2_CHECKRIGHTSFORTASK (
- i_myid integer,
- i_taskid integer)
- returns (
- o_result smallint)
- as
- declare variable l_isgroup smallint;
- declare variable l_result smallint;
- declare variable l_employerid integer;
- declare variable l_employerid2 integer;
- declare variable l_taskauthorid integer;
- declare variable l_taskemployerid integer;
- begin
- /* Проверка, имеет ли пользователь права на задачу */
- O_RESULT=0;
- if (exists(select id_task from grouptask g where g.id_task=:i_taskid and g.id_employer=:i_myid)) then
- begin
- O_RESULT = 1;
- suspend;
- exit;
- end
- if (O_RESULT = 0) then
- for select o_employerid
- from getemployeraliases(:i_myid)
- into :l_employerid2
- do
- begin
- select O_RESULT
- from INFORMER2_CHECKRIGHTSFORTASK(:l_employerid2, :i_taskid)
- into :O_RESULT;
- if (O_RESULT = 1) then
- begin
- suspend;
- exit;
- end
- end
- O_RESULT = 0;
- suspend;
- end^
- SET TERM ; ^
- commit;
- /*INFORMER2_GETMYTASKS*/
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE INFORMER2_GETMYTASKS (
- id_employer integer,
- ataskid integer,
- mintaskid integer)
- returns (
- taskid integer,
- taskname varchar(2000),
- isviewed smallint,
- isgroup smallint,
- isnewmessages smallint,
- amiauthor smallint,
- prjid integer,
- isreported smallint,
- authorid integer,
- empid integer,
- isrejected smallint,
- iswithreport smallint,
- lastactid integer,
- taskdesc varchar(10000),
- startdate timestamp,
- enddate timestamp,
- actcount integer,
- att varchar(24000),
- task_type smallint,
- ordertype smallint,
- documentid integer,
- priority smallint,
- lastactdate timestamp,
- empsid varchar(5000),
- deppath varchar(2000),
- state smallint,
- lastact varchar(10000),
- lastactempid integer,
- isonlyforview smallint,
- userid integer,
- mycolor smallint,
- send_actions smallint,
- receive_mail smallint,
- receive_sms smallint,
- acount integer,
- lastacount integer,
- documentname varchar(1000),
- documenttypeid integer,
- isresolution smallint,
- id_realauthor integer,
- id_taskinitiator integer,
- docversion integer,
- btn varchar(200),
- parentid integer,
- showdate timestamp,
- idfolder integer,
- issecretary smallint,
- iscontrol smallint,
- ctrlsid varchar(2000),
- signsid varchar(2000),
- is_have_isolated smallint,
- sysactcount integer,
- meansactcount integer,
- id_checkpoint integer,
- id_meta_dictionary integer,
- nrecord_tasktype integer,
- authorsid varchar(2000),
- mainempsid varchar(2000),
- numerator varchar(100),
- issecret smallint,
- newactcount integer,
- is_commited smallint,
- ctrlid integer,
- id_last_viewed_act integer,
- lastchange timestamp,
- isuseparentdocs smallint,
- is_show_task smallint)
- as
- declare variable gt_lastchange timestamp;
- declare variable ta_lastchange timestamp;
- declare variable i integer;
- declare variable cnt integer;
- declare variable execdocumentid varchar(1000);
- declare variable l_ishidden integer;
- declare variable sid integer;
- begin
- for select TASKID, TASKNAME, ISGROUP,
- AMIAUTHOR, PRJID, IsReported,
- /* AuthorId, EmpId, */IsRejected, IsWithReport,
- taskdesc, startdate, enddate, task_type,
- documentid, priority, deppath, state, IsOnlyForView, UserId, Send_Actions,
- ExecDocumentId, ID_REALAUTHOR, ID_TASKINITIATOR, PARENTID, is_have_isolated, id_checkpoint
- , id_meta_dictionary, nrecord_tasktype,numerator
- from Informer2_Getmytasks1(:ID_EMPLOYER, :ATASKID)
- into :TASKID, :TASKNAME, :ISGROUP,
- :AMIAUTHOR, :PRJID, :IsReported,
- /* :AuthorId, :EmpId,*/ :IsRejected, :IsWithReport,
- :taskdesc, :startdate, :enddate, :task_type,
- :documentid, :priority, :deppath, :state, :IsOnlyForView, :UserId, :Send_Actions,
- :ExecDocumentId, :ID_REALAUTHOR, :ID_TASKINITIATOR,:PARENTID, :is_have_isolated, :id_checkpoint
- ,:id_meta_dictionary, :nrecord_tasktype,:numerator
- do
- if (TaskId=ATaskId or TaskId>MinTaskId)
- then begin
- if (DocumentId is null and ExecDocumentId is null) then OrderType=0;
- else
- if (DocumentId is not null) then OrderType=1;
- else
- if (ExecDocumentId is not null)
- then begin
- OrderType=2;
- DocumentId=ExecDocumentId;
- end
- ISNEWMESSAGES=0;
- EXECUTE PROCEDURE informer2_gettaskids(ID_EMPLOYER, TASKID, IsOnlyForView) returning_values :EMPSID, :CTRLSID, :SIGNSID,
- :AuthorId, :EmpId , :AUTHORSID , :MAINEMPSID, :CTRLID;
- LastActDate=NULL;
- LastActId=-1;
- LastActId=-1;
- ActCount=0;
- LASTACT='';
- LASTACTEMPID=-1;
- idfolder=0;
- newactcount=0;
- MyColor=NULL;
- cnt=NULL;
- select ta.marker_color, ta.count_actions_view, ta.is_view_new_actions, ta.Id_last_viewed_action
- from task_attributes ta
- where ta.id_employer=:id_employer and
- ta.id_task=:taskid
- into :mycolor, :cnt, :ISNEWMESSAGES, :Id_last_viewed_act;
- select o_result
- from CheckTaskViewed(:ID_EMPLOYER, :taskid)
- into :isviewed;
- select t.la_id, t.action_count, t.sysaction_count, t.meansaction_count, t.issecret, t.isuseparentdocs
- from Task t
- where id= :TaskId
- into :LastActId, :ActCount, :sysactcount, :meansactcount, :issecret, :isuseparentdocs;
- if (isuseparentdocs=1) then
- begin
- SELECT O_DocumentID, O_DocumentName FROM getparentdocs(:TaskID)
- into :Documentid, :Documentname;
- end
- if (ActCount is null) then ActCount=0;
- ACount=ActCount;
- if ((ISNEWMESSAGES=1)or(ISNEWMESSAGES is null)or :ActCount=0)
- then ISNEWMESSAGES=0;
- else ISNEWMESSAGES=1;
- if (LastActId is null) then LastActId=0;
- if (LastActId>0) then
- begin
- select adate, Name, ID_Employer
- from Actions
- where id= :LastActId
- into :LastActDate, :LASTACT, :LASTACTEMPID;
- end
- execute procedure Informer2_TaskAtt(:taskid, -1, -1)
- returning_values :att;
- if (MyColor is null) then MyColor=0;
- select O_RECIVE_SMS, O_RECIVE_MAIL
- from GET_TASK_MAIL_SMS(:TaskId, :id_employer)
- into :receive_sms, :receive_mail;
- if (cnt is null) then lastacount=0;
- else lastacount=cnt;
- newactcount=acount-lastacount;
- isresolution=null;
- btn=null;
- select first 1 rt.isresolution, rt.button_caption from routetrees rt
- where rt.id_task = :taskid and
- rt.isvirtual = 0 and
- rt.isdeleted = 0 and
- (exists(select id from routenode rn
- where rn.id_routetree = rt.id and
- rn.id_employer = :id_employer and
- rn.isdeleted = 0))
- into :isresolution, :btn;
- if (isresolution is null) then isresolution=0;
- DocumentName='';
- DocumentTypeId=NULL;
- DocVersion=NULL;
- select Field1, ID_DocType, Doc_Version
- from Documents
- where id= :DocumentId
- into :DocumentName, :DocumentTypeId, :DocVersion;
- i=1;
- if (OrderType=1) then
- begin
- select O_result from documentcommited (:id_employer, :taskid)
- into :is_commited;
- if (is_commited=1) then
- if (not (exists(select first 1 id_task from grouptask where id_task=:TaskId and
- id_employer=:ID_employer and is_controler=1)))
- then i=0;
- end
- else is_commited=0;
- if (IsOnlyForView is null) then IsOnlyForView=0;
- if (IsOnlyForView=1) then
- begin
- /* SignsId=''; */
- if (exists (select first 1 id
- from Actions
- where id_task=:TaskId and
- examinated=1 and
- (id_employer= :id_employer or id_employer in (select O_EMPLOYERID from
- GETEMPLOYERALIASES(:id_employer)))
- ))
- then i=0;
- else begin
- i=1;
- end
- end
- /*if user needs information by the only one task,
- then return this task in any case*/
- if ((i=0) and (ATASKID<>-1)) then i=1;
- if (i=1) then
- begin
- showdate=NULL;
- select gt.show_task_date
- from grouptask gt
- where gt.id_task=:taskid and gt.id_employer=:id_employer
- into :showdate;
- ISSECRETARY=0;
- if (exists(select * from grouptask gr where gr.id_task=:TaskId
- AND GR.id_employer=:id_employer and gr.is_shadow=1)) then
- ISSECRETARY=1;
- --повесит пережитком
- ISCONTROL=0;
- SELECT
- t.lastchange,
- ta.lastchange,
- gt.lastchange
- FROM
- task t
- left join task_attributes ta on (ta.id_task = t.id and ta.id_employer = :id_employer)
- left join grouptask gt on (gt.id_task = t.id and gt.id_employer = :id_employer)
- WHERE
- t.id = :taskid
- INTO
- :lastchange,
- :ta_lastchange,
- :gt_lastchange;
- if (:ta_lastchange > :lastchange) then
- begin
- lastchange = :ta_lastchange;
- end
- if (:gt_lastchange > :lastchange) then
- begin
- lastchange = :gt_lastchange;
- end
- is_show_task = 0;
- if (is_show_task = 0) then
- begin
- if (exists ( select
- first (1) gt.id_task
- from
- grouptask gt
- where
- gt.id_task = :taskid and
- (
- gt.id_original = :id_employer OR
- gt.id_original = (select parentid from employer where id = :id_employer)
- )
- and
- (
- gt.is_author = 1 OR
- gt.is_respperson = 1 OR
- gt.is_worker = 1 OR
- gt.is_controler = 1 OR
- gt.is_shadow = 1
- )
- )
- )
- then
- is_show_task = 1;
- if (is_show_task = 1) then
- if (exists( select
- first (1) gt.id_task
- from
- grouptask gt
- join task t on
- t.id = gt.id_task
- where
- gt.id_task = :taskid and
- t.is_isolated = 1 and
- (
- gt.id_original = :id_employer OR
- gt.id_original = (select parentid from employer where id = :id_employer)
- )
- and
- (
- gt.is_author = 1 OR
- gt.is_respperson = 1 OR
- gt.is_worker = 1 OR
- gt.is_controler = 1 OR
- gt.is_shadow = 1
- )
- and exists
- (
- select
- first (1) id_task
- from
- grouptask
- where
- id_task = (select parentid from task where id = :taskid) and
- (
- id_original = :id_employer OR
- id_original = (select parentid from employer where id = :id_employer)
- )
- and
- (
- is_author = 1 OR
- is_respperson = 1 OR
- is_worker = 1 OR
- is_controler = 1 OR
- is_shadow = 1
- )
- )
- )
- )
- then
- is_show_task = 0;
- end
- suspend;
- end
- end
- end^
- SET TERM ; ^
- commit;
- /*INFORMER2_GETMYTASKS1*/
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE INFORMER2_GETMYTASKS1 (
- id_employer integer,
- ataskid integer)
- returns (
- taskid integer,
- taskname varchar(2000),
- isgroup smallint,
- amiauthor smallint,
- prjid integer,
- isreported smallint,
- authorid integer,
- empid integer,
- isrejected smallint,
- iswithreport smallint,
- taskdesc varchar(10000),
- startdate timestamp,
- enddate timestamp,
- task_type smallint,
- documentid integer,
- priority smallint,
- deppath varchar(2000),
- state smallint,
- isonlyforview smallint,
- userid integer,
- send_actions smallint,
- execdocumentid integer,
- id_realauthor integer,
- id_taskinitiator integer,
- parentid integer,
- is_have_isolated integer,
- id_checkpoint integer,
- id_meta_dictionary integer,
- nrecord_tasktype integer,
- numerator varchar(1000))
- as
- declare variable i integer;
- declare variable is_author integer;
- declare variable is_respperson integer;
- declare variable is_controller integer;
- declare variable is_worker integer;
- declare variable is_shadow integer;
- declare variable tid integer;
- declare variable id_dep integer;
- begin
- UserId=ID_EMPLOYER;
- TASK_TYPE = 0;
- if (ATaskId<>-1)
- then
- begin
- select O_RESULT
- from CHECKRIGHTSFORTASK(:ID_EMPLOYER, :ATASKID)
- into :i;
- if (i=0 or (i is null) )
- then begin
- TaskId=-1;
- suspend;
- exit;
- end
- select
- t.id, t.name, t.isgroup, t.id_project, t.isreported,
- (case dt.id_task when dt.id_task then 2 else t.isrejected
- end), t.iswithreport,
- t.description, t.startdate, t.enddate, t.id_document,
- t.Priority,
- t.State, t.IsOnlyForView, t.Send_Actions,
- t.ID_Document_Exec, t.ID_REALAUTHOR, t.ID_TASKINITIATOR,t.PARENTID,
- t.is_have_isolated, t.id_checkpoint, t.id_meta_dictionary, t.nrecord_tasktype,t.numerator
- from task t
- left join documenttaskrestore dt on dt.id_task = t.id
- where t.Id= :ATaskId
- into :TASKID, :TASKNAME, :ISGROUP,
- :PrjId, :IsReported,
- :IsRejected, :iswithreport,
- :taskdesc, :startdate, :enddate, :documentid,
- :Priority, :State, :IsOnlyForView, :Send_Actions,
- :ExecDocumentId, :ID_REALAUTHOR, :ID_TASKINITIATOR,:PARENTID,
- :is_have_isolated, :id_checkpoint, :id_meta_dictionary, :nrecord_tasktype,:numerator;
- /*вычисляем deppath*/
- deppath = null;
- select
- d.deppath
- from
- task t
- join department d on
- d.id = t.id_department
- where
- t.id = :ataskid
- into
- :deppath;
- if (deppath is null) then
- begin
- select first (1)
- d.deppath, d.id
- from
- grouptask g
- join task t on g.id_task = t.id
- join employer e on g.id_employer = e.id
- join department d on e.id_department = d.id
- where
- g.id_task = :ATaskID and
- g.is_respperson = 1
- into :DepPath, :id_dep;
- update task set id_department =:id_dep where id = :ataskid;
- end
- suspend;
- exit;
- end
- for select gt.id_task
- from grouptask gt, task t
- where gt.id_original=:id_employer
- and gt.task_state=0
- and t.id=gt.id_task
- and
- (
- (gt.is_show_task=1)
- or ((t.id_document>0)and(t.is_isolated=0)and(gt.is_controler=1))
- )
- into :TID
- do begin
- select
- t.id, t.name, t.isgroup, t.id_project, t.isreported,
- t.isrejected, t.iswithreport,
- t.description,
- t.startdate, t.enddate, t.id_document,
- t.Priority, t.State, t.IsOnlyForView, t.Send_Actions,
- t.ID_Document_Exec, t.ID_REALAUTHOR, t.ID_TASKINITIATOR,t.PARENTID,
- t.is_have_isolated, t.id_checkpoint,
- t.id_meta_dictionary, t.nrecord_tasktype,t.numerator
- from task t
- where t.id=:TID
- into :TASKID, :TASKNAME,
- :ISGROUP, :PrjId, :IsReported,
- :IsRejected, :iswithreport,
- :taskdesc, :startdate, :enddate, :documentid,
- :Priority, :State, :IsOnlyForView, :send_actions ,
- :ExecDocumentId, :ID_REALAUTHOR,
- :ID_TASKINITIATOR,:PARENTID,
- :is_have_isolated, :id_checkpoint, :id_meta_dictionary, :nrecord_tasktype,:numerator;
- AMIAUTHOR=0;
- for
- select g.is_author
- from grouptask g
- where g.id_task=:TID and
- g.id_original=:id_Employer
- into :is_author
- do begin
- is_author=is_author;
- if (is_author=1)
- then AMIAUTHOR=1;
- end
- suspend;
- end
- end ^
- SET TERM ; ^
- commit;
- /*INFORMER2_GETMYTASKS_WOR*/
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE INFORMER2_GETMYTASKS_WOR (
- id_employer integer,
- ataskid integer,
- mintaskid integer)
- returns (
- taskid integer,
- taskname varchar(2000),
- isviewed smallint,
- isgroup smallint,
- isnewmessages smallint,
- amiauthor smallint,
- prjid integer,
- isreported smallint,
- authorid integer,
- empid integer,
- isrejected smallint,
- iswithreport smallint,
- lastactid integer,
- taskdesc varchar(10000),
- startdate timestamp,
- enddate timestamp,
- actcount integer,
- att varchar(6000),
- task_type smallint,
- ordertype smallint,
- documentid integer,
- priority smallint,
- lastactdate timestamp,
- empsid varchar(6000),
- deppath varchar(2000),
- state smallint,
- lastact varchar(10000),
- lastactempid integer,
- isonlyforview smallint,
- userid integer,
- mycolor smallint,
- send_actions smallint,
- receive_mail smallint,
- receive_sms smallint,
- acount integer,
- lastacount integer,
- documentname varchar(1000),
- documenttypeid integer,
- isresolution smallint,
- id_realauthor integer,
- id_taskinitiator integer,
- docversion integer,
- btn varchar(200),
- parentid integer,
- showdate timestamp,
- idfolder integer,
- issecretary smallint,
- iscontrol smallint,
- ctrlsid varchar(2000),
- signsid varchar(2000),
- id_meta_dictionary integer,
- nrecord_tasktype integer,
- authorsid varchar(2000),
- mainempsid varchar(2000),
- numerator varchar(100),
- issecret smallint)
- as
- declare variable i integer;
- declare variable cnt integer;
- declare variable execdocumentid varchar(1000);
- declare variable l_ishidden integer;
- declare variable sid integer;
- begin
- for select TASKID, TASKNAME, ISGROUP,
- AMIAUTHOR, PRJID, IsReported,
- /* AuthorId, EmpId,*/ IsRejected, IsWithReport,
- taskdesc, startdate, enddate, task_type,
- documentid, priority, deppath, state, IsOnlyForView, UserId, Send_Actions,
- ExecDocumentId, ID_REALAUTHOR, ID_TASKINITIATOR, PARENTID, numerator
- from Informer2_Getmytasks1(:ID_EMPLOYER, :ATASKID)
- into :TASKID, :TASKNAME, :ISGROUP,
- :AMIAUTHOR, :PRJID, :IsReported,
- /* :AuthorId, :EmpId,*/ :IsRejected, :IsWithReport,
- :taskdesc, :startdate, :enddate, :task_type,
- :documentid, :priority, :deppath, :state, :IsOnlyForView, :UserId, :Send_Actions,
- :ExecDocumentId, :ID_REALAUTHOR, :ID_TASKINITIATOR,:PARENTID, :numerator
- do
- if (TaskId=ATaskId or TaskId>MinTaskId ) then
- begin
- if (DocumentId is null and ExecDocumentId is null) then OrderType=0;
- else
- if (DocumentId is not null) then OrderType=1;
- else
- if (ExecDocumentId is not null) then
- begin
- OrderType=2;
- DocumentId=ExecDocumentId;
- end
- ISNEWMESSAGES=0;
- select ig.Empsid, ig.Ctrlsid, ig.Signsid, ig.Authorid, ig.Empid, ig.Authorsid, ig.Mainempsid
- from informer2_gettaskids(:ID_EMPLOYER,:TASKID,:IsOnlyForView) ig
- into :EMPSID, :CTRLSID, :SIGNSID, :AuthorId, :EmpId , :AUTHORSID , :MAINEMPSID;
- LastActDate=NULL;
- LastActId=-1;
- ActCount=0;
- LASTACT='';
- LASTACTEMPID=-1;
- select t.la_id, t.action_count
- from Task t
- where id= :TaskId
- into :LastActId, :ActCount;
- if (LastActId is null) then LastActId=0;
- if (LastActId>0) then
- begin
- select adate, Name, ID_Employer
- from Actions
- where id= :LastActId
- into :LastActDate, :LASTACT, :LASTACTEMPID;
- end
- if (ActCount is null) then ActCount=0;
- ACount=ActCount;
- execute procedure Informer2_TaskAtt(:taskid, :documentid, -1) returning_values :att;
- LastActDate=NULL;
- LastActId=-1;
- ActCount=0;
- LASTACT='';
- LASTACTEMPID=-1;
- idfolder=0;
- MyColor=NULL;
- select ta.marker_color, ta.count_actions_view, ta.is_view_new_actions
- from task_attributes ta
- where ta.id_employer=:id_employer and
- ta.id_task=:taskid
- into :mycolor, :cnt, :ISNEWMESSAGES;
- select o_result
- from CheckTaskViewed(:ID_EMPLOYER, :taskid)
- into :isviewed;
- if (MyColor is null) then MyColor=0;
- select O_RECIVE_SMS, O_RECIVE_MAIL
- from GET_TASK_MAIL_SMS(:TaskId, :id_employer)
- into :receive_sms, :receive_mail;
- if (cnt is null) then lastacount=0;
- else lastacount=cnt;
- isresolution=null;
- btn=null;
- select first 1 rt.isresolution, rt.button_caption from routetrees rt
- where rt.id_task = :taskid and
- rt.isvirtual = 0 and
- rt.isdeleted = 0 and
- (exists(select id from routenode rn
- where rn.id_routetree = rt.id and
- rn.id_employer = :id_employer and
- rn.isdeleted = 0))
- into :isresolution, :btn;
- if (isresolution is null) then isresolution=0;
- DocumentName='';
- DocumentTypeId=NULL;
- DocVersion=NULL;
- select Field1, ID_DocType, Doc_Version
- from Documents
- where id= :DocumentId
- into :DocumentName, :DocumentTypeId, :DocVersion;
- if (OrderType=1) then
- begin
- select O_result from documentcommited (:id_employer, :taskid)
- into :i;
- if (i=1) then i=0;
- else i=1;
- end
- else i=1;
- if (IsOnlyForView is null) then IsOnlyForView=0;
- if (IsOnlyForView=1) then
- begin
- SignsId='';
- if (exists (select first 1 id
- from Actions
- where id_task=:TaskId and
- examinated=1 and
- (id_employer= :id_employer or id_employer in (select O_EMPLOYERID from GETEMPLOYERALIASES(:id_employer)))
- ))
- then i=0;
- else begin -- задача
- i=1;
- end
- end
- if (i=1) then
- begin
- showdate=NULL;
- select ht.showdate
- from hiddentasks ht
- where ht.id_task=:taskid and ht.id_employer=:id_employer
- into :showdate;
- ISSECRETARY=0;
- if (ISGROUP=1) then
- BEGIN
- if (exists(select * from grouptask gr where gr.id_task=:TaskId
- AND GR.id_employer=:id_employer and gr.is_shadow=1)) then
- ISSECRETARY=1;
- END
- ISCONTROL=0;
- /* suspend; */
- end
- suspend;
- end
- end^
- SET TERM ; ^
- commit;
- /*INFORMER2_GETMYWORKGR*/
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE INFORMER2_GETMYWORKGR (
- empid integer,
- taskid_ integer)
- returns (
- taskid integer,
- parenttaskid integer,
- empsid varchar(4000),
- cascadepostsystemactions integer,
- taskstate smallint,
- wgids varchar(4000),
- iwg_name varchar(2000))
- as
- declare variable tid integer;
- declare variable mempid integer;
- declare variable isreported integer;
- begin
- /* Procedure Text */
- if (taskid_<>-1)
- then begin
- for
- select tt.id, tt.IS_POST_SYSACTIONS_TO_PARENT, tt.parentid, tt.state, tt.isreported, tt.irg_name
- from task tt
- where (tt.parentid=:taskid_) and (tt.is_isolated=1)
- into :taskid, :cascadepostsystemactions, :PARENTTASKID, :taskstate, :iSREPORTED, :IWG_NAME
- do begin
- select EMPSID, MAINEMPSID from informer2_gettaskids(:EMPID, :taskid, 0)
- into :WGIDS, :EMPSID;
- /* EMPSID=:MEMPID||';'||:EMPSID; */
- if ((:taskstate<>1)and(:iSREPORTED=1)) then taskstate=2;
- suspend;
- end
- end
- else
- for select gt.id_task
- from grouptask gt, task t
- where gt.id_original=:empid and gt.task_state=0 and gt.is_show_task=1
- and t.id=gt.id_task and t.is_have_isolated=1
- into :PARENTTASKID
- do begin
- for
- select tt.id, tt.IS_POST_SYSACTIONS_TO_PARENT, tt.state, tt.isreported,
- tt.irg_name
- from task tt
- where (tt.parentid=:PARENTTASKID) and (tt.is_isolated=1)
- into :taskid, :cascadepostsystemactions, :taskstate, :ISREported, :IWG_NAME
- do begin
- select EMPSID, MAINEMPSID from informer2_gettaskids(:EMPID, :taskid, 0)
- into :WGIDS, :EMPSID;
- if ((:taskstate<>1)and(:iSREPORTED=1)) then taskstate=2;
- suspend;
- end
- end
- end^
- SET TERM ; ^
- commit;
- /*INFORMER2_NEWACTIONSFOREMPLOYER*/
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE INFORMER2_NEWACTIONSFOREMPLOYER (
- minactid integer,
- employerid integer)
- returns (
- actid integer,
- act varchar(10000),
- adate timestamp,
- class smallint,
- empid integer,
- taskid integer,
- att varchar(8000),
- signature blob sub_type 0 segment size 80,
- subtaskid integer,
- id_document integer,
- docname varchar(1000),
- doctype varchar(200),
- doc_create_date timestamp,
- docauthor varchar(2000))
- as
- declare variable filename varchar(260);
- declare variable description varchar(200);
- declare variable displayfilename varchar(1000);
- declare variable i integer;
- BEGIN
- /* для снятия нагрузки*/
- if (gen_id(GEN_ENABLED_INF_PROC,0)<>1) then exit;
- if (MinActId=0) then exit;
- for
- select distinct gt.id_task
- from grouptask gt
- where gt.id_original=:EMPLOYERID and gt.task_state=0 and gt.is_show_task=1
- into :TaskId
- do
- begin
- FOR
- select a.NAME,a.id_document, d.field1 as docname, dt.name as doctype,d.createdate as Doc_Create_Date,e.name as DocAuthor,
- a.ADATE, a.id, a.class, a.id_employer, a.signature, a.id_subtask
- from ACTIONS a
- left join documents d on (d.id = a.id_document)
- left join doctypes dt on (dt.id=d.id_doctype)
- left join employer e on (e.id=d.id_author)
- where a.ID>:MinActId and a.ID_Task= :TaskId
- order by a.Id_Task, a.Adate
- INTO :Act,:id_document,:docname,:doctype, :doc_create_date, :docauthor, :ADate, :ActId, :Class, :EmpId,:Signature, :subtaskid
- DO
- BEGIN
- Att='';
- if (subtaskid is null) then subtaskid=0;
- for select FILENAME, DESCRIPTION, displayfilename
- from ATTACHMENT
- where ISDELETED=0 and ID_ACTION=:ActId
- into :FileName, :Description,:displayfilename
- do
- begin
- if (Description is null) then Description='';
- if (DisplayFileName is null) then DisplayFileName=FileName;
- Att=Att||'/Upload/'||:TaskId||'/'||FileName||'<,>'||Description||'<,>'||DisplayFileName||'<;>';
- end
- SUSPEND;
- END
- end
- END^
- SET TERM ; ^
- commit;
- /*task_au0*/
- SET TERM ^ ;
- CREATE OR ALTER trigger task_au0 for task
- active before update position 0
- as
- declare variable task_id int;
- declare variable task_count int;
- declare variable l_idroutetree integer;
- declare variable l_idemployer integer;
- declare variable l_idnotice integer;
- declare variable l_id_docexec integer;
- declare variable l_task_valuation_id integer;
- begin
- --закрывается, без доклада
- if (new.iswithreport = 0 and old.state = 0 and new.state = 1) then new.tsreport = 'now';
- --доклад отправлен, задача не закрыта
- if (new.iswithreport = 1) then
- begin
- --anee aieeaa ioi?aaeai, ii caaa?a au? ia cae?uoa
- if (old.isreported=0 and new.isreported=1 and new.state = 0) then
- new.respp_report = 'now';
- --задача закрыта
- if (old.state = 0 and new.state = 1) then
- new.tsreport = 'now';
- --возвращена на доработку
- if (old.isreported=1 and new.isreported=0 and new.state = 0) then
- new.respp_report = null;
- end
- if (new.isdeleted=1 and old.isdeleted =0) then /*удаляем задачу - удаляем атачи */
- begin
- update attachment set isdeleted = 1
- where id_task=new.id;
- /* удаляем проект - кроме проекта по умолчанию */
- if (not exists(select id
- from task where
- id!=new.id and id_project=new.id_project and isdeleted=0)) then
- update project
- set isdeleted = 1
- where id=new.id_project and istrash=0;
- end
- if (new.isdeleted=1 and old.isdeleted =0) then /*удаляем задачу - удаляем атачи */
- begin
- update attachment set isdeleted = 1
- where id_task=new.id;
- end
- /* меняем task_state в grouptask */
- update grouptask set task_state=new.state
- where id_task=new.id and (task_state != new.state or task_state is null);
- if (new.state =1 and old.state = 0) then /*закрытие задачи - снимаем с контроля*/
- begin
- delete from hiddentasks where id_task=new.id;
- select count (id) from task
- where id_project =old.id_project
- and state= 0
- into :task_count;
- if (task_count =1) then /*последняя задача - закрываем проект*/
- begin
- select id from task where id_project = new.id_project
- and state =0
- into :task_id;
- if (task_id = old.id) then
- update project
- set state=1
- where id=old.id_project;
- end
- /*напоминания*/
- for select n.id from notice n where n.id_task = new.id
- into :l_idnotice do
- begin
- execute procedure delete_notice(:l_idnotice);
- end
- end
- if (new.state = 0 and old.state = 1) then /*восстановление задачи + проект*/
- begin
- update project set state=0
- where id=new.id_project and state!=0;
- new.id_valuation=null;/*сбрасываем оценку восстановленной*/
- update grouptask gt set gt.is_viewed_task=0 where gt.id_task=new.id;
- update actions a set a.examinated=0 where a.examinated=1 and a.id_task=new.id;
- end
- if (new.id_project <> old.id_project) then --ia?aiin ec i?iaeoa a i?iaeo - ia?aiinei ana oianeaaiaaiiua caaa?e
- begin
- /*закрываем проект*/
- select count (id) from task
- where id_project =old.id_project
- and state= 0
- into :task_count;
- if (task_count =1) then
- begin
- select id from task where id_project = old.id_project
- and state =0
- into :task_id;
- if (task_id = old.id) then
- update project set state=1
- where id=old.id_project;
- end
- end
- end^
- SET TERM ; ^
- commit;
- /*и удалим все что лишнее*/
- SET TERM ^ ;
- CREATE OR ALTER PROCEDURE TMP_DROP_FAVORITS
- AS
- declare variable is_exist smallint;
- BEGIN
- /*сначала процедуры. эти две темповые процедуры непонятно откуда взялись*/
- SELECT result FROM IS_PROCEDURE_EXISTS('TMP_CONVERT_FAVTASKS')
- INTO :is_exist;
- IF (is_exist = 1) THEN
- begin
- EXECUTE STATEMENT
- 'DROP PROCEDURE TMP_CONVERT_FAVTASKS;';
- end
- SELECT result FROM IS_PROCEDURE_EXISTS('TMP_DEL_CLOSED_FAVORITES')
- INTO :is_exist;
- IF (is_exist = 1) THEN
- begin
- EXECUTE STATEMENT
- 'DROP PROCEDURE TMP_DEL_CLOSED_FAVORITES;';
- end
- /*это специфичная для этой таблицы процедуры, легко удаляем*/
- SELECT result FROM IS_PROCEDURE_EXISTS('GETFAVORITETASK')
- INTO :is_exist;
- IF (is_exist = 1) THEN
- begin
- EXECUTE STATEMENT
- 'DROP PROCEDURE GETFAVORITETASK;';
- end
- SELECT result FROM IS_PROCEDURE_EXISTS('SETCONTROL')
- INTO :is_exist;
- IF (is_exist = 1) THEN
- begin
- EXECUTE STATEMENT
- 'DROP PROCEDURE SETCONTROL;';
- end
- /*поля*/
- SELECT result FROM IS_FIELD_EXISTS('FAVORITETASKS', 'ID_TASK')
- INTO :is_exist;
- IF (is_exist = 1) THEN
- begin
- EXECUTE STATEMENT
- 'ALTER TABLE FAVORITETASKS DROP CONSTRAINT FK_FAVORITETASKS2;';
- EXECUTE STATEMENT
- 'ALTER TABLE FAVORITETASKS DROP ID_TASK;';
- end
- SELECT result FROM IS_FIELD_EXISTS('FAVORITETASKS', 'ID_EMPLOYER')
- INTO :is_exist;
- IF (is_exist = 1) THEN
- begin
- EXECUTE STATEMENT
- 'ALTER TABLE FAVORITETASKS DROP CONSTRAINT FK_FAVORITETASKS1;';
- EXECUTE STATEMENT
- 'ALTER TABLE FAVORITETASKS DROP ID_EMPLOYER;';
- end
- /*сама таблица*/
- SELECT result FROM IS_TABLE_EXISTS('FAVORITETASKS')
- INTO :is_exist;
- IF (is_exist = 1) THEN
- begin
- EXECUTE STATEMENT
- 'DROP TABLE FAVORITETASKS';
- end
- END ^
- SET TERM ; ^
- commit;
- EXECUTE PROCEDURE TMP_DROP_FAVORITS;
- commit;
- DROP PROCEDURE TMP_DROP_FAVORITS;
- commit;
- /*-------------------------------------------------------------------------------------------------------------------------------*/
- /* ������� ��� �������� ������ ���������� �������� */
- /*-------------------------------------------------------------------------------------------------------------------------------*/
- CREATE TABLE INDEXING_ERRORS (
- ID INTEGER NOT NULL,
- OBJECT_TYPE INTEGER NOT NULL,
- OBJECT_ID INTEGER NOT NULL,
- INFO VARCHAR(1024) NOT NULL,
- EXTENDED_INFO VARCHAR(4096),
- PRIMARY KEY (ID),
- UNIQUE (OBJECT_TYPE, OBJECT_ID)
- );
- CREATE GENERATOR GEN_INDEXING_ERRORS;
- SET TERM ^ ;
- CREATE TRIGGER INDEXING_ERRORS_BI FOR INDEXING_ERRORS
- ACTIVE BEFORE INSERT POSITION 0
- AS
- BEGIN
- if (NEW.ID is NULL) then NEW.ID = GEN_ID(GEN_INDEXING_ERRORS, 1);
- END^
- SET TERM ; ^
- commit;
- commit;
- commit work;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement