Установка технологических карт — различия между версиями

Материал из wiki.standart-n.ru
Перейти к: навигация, поиск
(В groups.id=-446 загрузить скрипт)
Строка 1: Строка 1:
 
==В groups "Редактирование поля" загрузить тмс==
 
==В groups "Редактирование поля" загрузить тмс==
 
[[Файл: -446.rar]]
 
[[Файл: -446.rar]]
 +
 +
==После выполнения скрипта загрузить сетку в таблицу тех.карты==
 +
[[Файл: Сетка_техкарты.rar ]]
  
 
==Выполнить скрипт==
 
==Выполнить скрипт==

Версия 11:44, 9 декабря 2016

В groups "Редактирование поля" загрузить тмс

Файл:-446.rar

После выполнения скрипта загрузить сетку в таблицу тех.карты

Файл:Сетка техкарты.rar

Выполнить скрипт

CREATE EXCEPTION EX_ING 'Не указано кол-во в упаковке ингридиента';
CREATE EXCEPTION EX_ING_PARTNOTFOUND 'При подборе ингридиентов не найдено ни одного';
/******************************************************************************/
/***               Generated by IBExpert 08.12.2016 17:42:56                ***/
/******************************************************************************/

/******************************************************************************/
/***      Following SET SQL DIALECT is just for the Database Comparer       ***/
/******************************************************************************/
SET SQL DIALECT 3;



/******************************************************************************/
/***                                 Tables                                 ***/
/******************************************************************************/


CREATE GENERATOR GEN_DOPINFOCENN_ID;

CREATE TABLE DOPINFOCENN (
    ID              DM_ID NOT NULL /* DM_ID = BIGINT */,
    DESCRIPTION_ID  DM_ID /* DM_ID = BIGINT */,
    VALS            DM_DOUBLE /* DM_DOUBLE = DOUBLE PRECISION */,
    NAME_ID         DM_ID /* DM_ID = BIGINT */,
    SORTING         DM_ID /* DM_ID = BIGINT */,
    EDIZM           DM_TEXT /* DM_TEXT = VARCHAR(250) */,
    BRUTTO          DM_DOUBLE /* DM_DOUBLE = DOUBLE PRECISION */,
    NETTO           DM_DOUBLE /* DM_DOUBLE = DOUBLE PRECISION */
);




/******************************************************************************/
/***                              Primary keys                              ***/
/******************************************************************************/

ALTER TABLE DOPINFOCENN ADD CONSTRAINT PK_DOPINFOCENN PRIMARY KEY (ID);


/******************************************************************************/
/***                                Triggers                                ***/
/******************************************************************************/



SET TERM ^ ;



/******************************************************************************/
/***                          Triggers for tables                           ***/
/******************************************************************************/



/* Trigger: DOPINFOCENN_BI */
CREATE OR ALTER TRIGGER DOPINFOCENN_BI FOR DOPINFOCENN
ACTIVE BEFORE INSERT POSITION 0
as
begin
  if (new.id is null) then
    new.id = gen_id(gen_dopinfocenn_id,1);
end
^


/* Trigger: DOPINFOCENN_BU0 */
CREATE OR ALTER TRIGGER DOPINFOCENN_BU0 FOR DOPINFOCENN
ACTIVE BEFORE UPDATE POSITION 0
AS
begin
  if (new.vals<>old.vals) then
   begin
    new.netto = new.vals;
    new.brutto = new.vals;
   end
  if (new.netto is null) then
   new.netto =new.vals;
  if (new.brutto is null) then
   new.brutto = new.vals;
end
^

SET TERM ; ^



/******************************************************************************/
/***                               Privileges                               ***/
/******************************************************************************/



/******************************************************************************/
/***               Generated by IBExpert 08.12.2016 17:43:11                ***/
/******************************************************************************/

/******************************************************************************/
/***      Following SET SQL DIALECT is just for the Database Comparer       ***/
/******************************************************************************/
SET SQL DIALECT 3;



/******************************************************************************/
/***                                 Tables                                 ***/
/******************************************************************************/


CREATE GENERATOR GEN_DESCRIPTION_ID;

CREATE TABLE DESCRIPTION (
    ID       DM_ID NOT NULL /* DM_ID = BIGINT */,
    CAPTION  DM_TEXT /* DM_TEXT = VARCHAR(250) */,
    STATUS   DM_ID DEFAULT 0 /* DM_ID = BIGINT */,
    EDIZM    DM_TEXT /* DM_TEXT = VARCHAR(250) */
);




/******************************************************************************/
/***                              Primary keys                              ***/
/******************************************************************************/

ALTER TABLE DESCRIPTION ADD CONSTRAINT PK_DESCRIPTION PRIMARY KEY (ID);


/******************************************************************************/
/***                                Triggers                                ***/
/******************************************************************************/



SET TERM ^ ;



/******************************************************************************/
/***                          Triggers for tables                           ***/
/******************************************************************************/



/* Trigger: DESCRIPTION_BI */
CREATE OR ALTER TRIGGER DESCRIPTION_BI FOR DESCRIPTION
ACTIVE BEFORE INSERT POSITION 0
as
begin
  if (new.id is null) then
    new.id = gen_id(gen_description_id,1);
end
^

SET TERM ; ^



/******************************************************************************/
/***                               Privileges                               ***/
/******************************************************************************/


/******************************************************************************/

/******************************************************************************/
/***      Following SET SQL DIALECT is just for the Database Comparer       ***/
/******************************************************************************/
SET SQL DIALECT 3;



/******************************************************************************/
/***                                 Views                                  ***/
/******************************************************************************/


/* View: VW_DOPINFOCENN */
CREATE OR ALTER VIEW VW_DOPINFOCENN(
    ID,
    DESCRIPTION_ID,
    VALS,
    NAME_ID,
    SNAME,
    SDESCRIPTION,
    SORTING,
    EDIZM,
    SEDIZM,
    BRUTTO,
    NETTO,
    PRICE)
AS
select
    id,
    description_id,
    vals,
    name_id,
    (select v.svalue from vals v where v.id=description_id),
    (select d.caption from DESCRIPTION d where d.id=description_id),
    sorting,
    edizm,
    (select v.svalue from vals v where v.id=edizm),
    brutto,
    netto,
    (select first 1 Trim(cast(w.price_o as NUMERIC(15,2))) ||' руб. за '||Trim(w.edizm) from warebase w where w.name_id=DESCRIPTION_ID order by w.part_id desc)
from dopinfocenn
;




/******************************************************************************/
/***                               Privileges                               ***/
/******************************************************************************/


SET TERM ^ ;

create or alter procedure PR_RASHOD_ING (
    DOC_ID DM_ID)
as
declare variable INITAGENT_ID DM_ID;
declare variable SESSION_ID DM_ID;
declare variable W_QUANT DM_DOUBLE;
declare variable NGTD DM_DOUBLE;
declare variable REALQUANT DM_DOUBLE;
declare variable QUANT_REC DM_ID;
declare variable QUANT DM_DOUBLE;
declare variable DETAIL_ID DM_ID;
declare variable QUANT_RASHOD DM_DOUBLE;
declare variable PART_ID DM_ID;
declare variable DESCRIPTION_ID DM_ID;
declare variable NAME_ID DM_ID;
declare variable NEW_DOC_ID DM_ID;
begin
   select d.audit_id, d.agent_id FROM docs d where d.id=:doc_id INTO :session_id,:initagent_id;
   select Count(id) from vw_doc_detail_active dd where dd.doc_id=:doc_id and dd.part_type=1 and
   dd.mmbsh not containing '87=' and dd.mmbsh not containing '80=' into :Quant_Rec;
   if (:quant_rec>0) then
    begin
      select doc_id from PR_NEWDOC(36,:initagent_id,0,null,null,:session_id) into :new_doc_id;
      update docs set parent_id=:doc_id where id=:new_doc_id;
     FOR
      select dd.name_id, dd.quant from doc_detail_active dd where dd.doc_id=:doc_id and part_type=1 INTO :name_id, :Quant
     do
      begin
        FOR
          select di.DESCRIPTION_ID, di.vals from DOPINFOCENN di
          where di.name_id=:name_id into :DESCRIPTION_ID,:QUANT_RASHOD do
          begin
            w_quant = 0;
            for
            select w.part_id,cast(iif(w.ngtd is NULL,1,replace(w.ngtd,',','.')) as NUMERIC(15,2)),w.realquant from warebase w
            where w.name_id=:description_id order by w.part_id into :part_id,:ngtd,:realquant do
             begin
              if (ngtd=0) then
               exception ex_ing;

              --w_quant=(w_quant / ngtd)*quant

              quant_rashod = (quant_rashod / ngtd)*quant;
--              w_quant = w_quant + realquant;
              if (realquant>=quant_rashod) then
               begin
                select id from pr_rashodpart(:new_doc_id, :part_id,-:quant_rashod,null,null,1,null,null,0,0) into :detail_id;
                update doc_detail_active set parent_id=:name_id where id=:detail_id;
                break;
               end
              else
               begin
                if (realquant>0) then
                 begin
                  select id from pr_rashodpart(:new_doc_id, :part_id,-:realquant,null,null,1,null,null,0,0) into :detail_id;
                  update doc_detail_active set parent_id=:name_id where id=:detail_id;
                  --w_quant = w_quant
                 end
               end
              if (w_quant>=quant_rashod) then
               break;
             end




          end
      end
     execute procedure pr_doc_commit(:new_doc_id,:session_id);
    end
end^

SET TERM ; ^

/* Following GRANT statements are generated automatically */

GRANT SELECT,UPDATE ON DOCS TO PROCEDURE PR_RASHOD_ING;
GRANT SELECT ON VW_DOC_DETAIL_ACTIVE TO PROCEDURE PR_RASHOD_ING;
GRANT EXECUTE ON PROCEDURE PR_NEWDOC TO PROCEDURE PR_RASHOD_ING;
GRANT SELECT,UPDATE ON DOC_DETAIL_ACTIVE TO PROCEDURE PR_RASHOD_ING;
GRANT SELECT ON DOPINFOCENN TO PROCEDURE PR_RASHOD_ING;
GRANT SELECT ON WAREBASE TO PROCEDURE PR_RASHOD_ING;
GRANT EXECUTE ON PROCEDURE PR_RASHODPART TO PROCEDURE PR_RASHOD_ING;
GRANT EXECUTE ON PROCEDURE PR_DOC_COMMIT TO PROCEDURE PR_RASHOD_ING;

/* Existing privileges on this procedure */

GRANT EXECUTE ON PROCEDURE PR_RASHOD_ING TO SYSDBA;

SET TERM ^ ;

create or alter procedure PR_RASHOD_ING_1 (
    DOC_ID DM_ID)
as
declare variable SESSION_ID DM_ID;
declare variable INITAGENT_ID DM_ID;
declare variable NEW_DOC_ID DM_ID;
declare variable NEED_QUANT DM_DOUBLE;
declare variable NAME_ID DM_ID;
declare variable DESCR_NAME_ID DM_ID;
declare variable DESCR_QUANT DM_DOUBLE;
declare variable QUANT_IN_PACK DM_DOUBLE;
declare variable REALQUANT DM_DOUBLE;
declare variable PART_ID DM_ID;
declare variable CUR_QUANT DM_DOUBLE;
declare variable CUR_RASHOD DM_DOUBLE;
declare variable DETAIL_ID DM_ID;
declare variable DETAIL_MSG DM_TEXT;
begin
  select d.audit_id, d.agent_id FROM docs d where d.id=:doc_id INTO :session_id,:initagent_id;
  if (not exists(select first 1 id from doc_detail_active dd where dd.doc_id=:doc_id and part_type=1)) then exit;
  select doc_id from PR_NEWDOC(36,:initagent_id,0,null,null,:session_id) into :new_doc_id;
  update docs set parent_id=:doc_id where id=:new_doc_id;
  for --бежим по блюдам
    select dd.name_id, dd.quant from doc_detail_active dd where dd.doc_id=:doc_id and part_type=1 INTO :name_id, :need_quant
  do
  begin
    for --бежим по ингридиентам
     select di.DESCRIPTION_ID, cast(replace(di.vals,',','.') as NUMERIC(15,2)) from DOPINFOCENN di
     where di.name_id=:name_id into :DESCR_NAME_ID,:DESCR_QUANT do
    begin
      CUR_RASHOD=0;
      DESCR_QUANT=-DESCR_QUANT*need_quant;
      part_id=NULL;
      for --бежим по остаткам
       select w.part_id,cast(iif(w.ngtd is NULL,1,replace(w.ngtd,',','.')) as NUMERIC(15,2)),w.realquant from warebase w
       where w.name_id=:DESCR_NAME_ID order by w.part_id into :part_id,:QUANT_IN_PACK,:realquant do
      begin
        if (realquant>0) then
        begin
          if (QUANT_IN_PACK=0) then exception ex_ing;
          CUR_QUANT=realquant*QUANT_IN_PACK;--посчитали скока есть по позиции в нужном измерении
          if (CUR_RASHOD>=DESCR_QUANT) then break; -- значить уже все списали
          if (CUR_QUANT>=(DESCR_QUANT-CUR_RASHOD)) then --если хватает кол-ва на остатках - списываем и выходим из цикла по остаткам текущего ингридиента
          begin
            select id from pr_rashodpart(:new_doc_id, :part_id,((:DESCR_QUANT-:CUR_RASHOD)/:QUANT_IN_PACK),null,null,1,null,null,0,0) into :detail_id;
            update doc_detail_active set parent_id=:name_id where id=:detail_id;
            CUR_RASHOD=DESCR_QUANT;
            break;
          end
          else -- иначе (не хватает) списываем что есть и переходим к след партии текущего ингридиента
          begin
            select id from pr_rashodpart(:new_doc_id, :part_id,:CUR_QUANT/:QUANT_IN_PACK,null,null,1,null,null,0,0) into :detail_id;
            update doc_detail_active set parent_id=:name_id where id=:detail_id;
            CUR_RASHOD=CUR_RASHOD+CUR_QUANT;
          end
        end
      end
      if (part_id is null) then -- похоже на остатках нет и в помине таких ингридиентов, ситуация исключительная, но проверить надо
        exception EX_ING_PARTNOTFOUND;
      if (CUR_RASHOD<DESCR_QUANT) then -- означает, что не хватило ингридиента на остатках, придеться идти в минус, как раз по последней просмотренной партии
      begin
        select id from pr_rashodpart(:new_doc_id, :part_id,((:DESCR_QUANT-:CUR_RASHOD)/:QUANT_IN_PACK),null,null,1,null,null,0,0) into :detail_id;
        update doc_detail_active set parent_id=:name_id where id=:detail_id;
      end
    end 
  end
  execute procedure pr_doc_commit(:new_doc_id,:session_id);
end^

SET TERM ; ^

/* Following GRANT statements are generated automatically */

GRANT SELECT,UPDATE ON DOCS TO PROCEDURE PR_RASHOD_ING_1;
GRANT SELECT,UPDATE ON DOC_DETAIL_ACTIVE TO PROCEDURE PR_RASHOD_ING_1;
GRANT EXECUTE ON PROCEDURE PR_NEWDOC TO PROCEDURE PR_RASHOD_ING_1;
GRANT SELECT ON DOPINFOCENN TO PROCEDURE PR_RASHOD_ING_1;
GRANT SELECT ON WAREBASE TO PROCEDURE PR_RASHOD_ING_1;
GRANT EXECUTE ON PROCEDURE PR_RASHODPART TO PROCEDURE PR_RASHOD_ING_1;
GRANT EXECUTE ON PROCEDURE PR_DOC_COMMIT TO PROCEDURE PR_RASHOD_ING_1;

/* Existing privileges on this procedure */

GRANT EXECUTE ON PROCEDURE PR_RASHOD_ING_1 TO SYSDBA;


SET SQL DIALECT 3;


SET TERM ^ ;

CREATE OR ALTER trigger warebase_bu0 for warebase
active before update position 0
AS
begin
if (new.quant<>old.quant) then
new.updatedt='now';
select
(select svalue from vals where id=t.name_id),
(select svalue from vals where id=t.izg_id),
(select svalue from vals where id=t.country_id),
orig_code,
(select svalue from vals where id=t.orig_name_id),
(select svalue from vals where id=t.orig_izg_id),
(select svalue from vals where id=t.orig_country_id),
barcode,
t.name_id,
t.izg_id,
t.country_id
from
wares t
where
t.id=new.ware_id
into
new.sname,
new.sizg,
new.scountry,
new.orig_code,
new.sorig_name,
new.sorig_izg,
new.sorig_country,
new.bcode_izg,
new.name_id,
new.izg_id,
new.country_id;
if (new.quant between -0.00001 and 0.00001) then
new.quant=0;
if (new.name_id <> old.name_id) then execute procedure PR_COPYGROUPS(old.name_id, new.name_id);

if (new.name_id<>old.name_id) then
   begin
    update dopinfocenn set name_id=new.name_id where name_id=old.name_id;
    if (new.part_type=1) then
     begin
      if (not exists (select id from GROUP_DETAIL where group_id=1 and GROUPTABLE='PARTS.NAME_ID' and GROUPTABLE_ID=new.name_id)) then
       insert into GROUP_DETAIL (GROUP_ID,PARENT_ID,GROUPTABLE_ID,GROUPTABLE) values (1,0,new.name_id,'PARTS.NAME_ID');
     end
     if (not exists (select id from GROUP_DETAIL where group_id=-11 and GROUPTABLE='PARTS.NAME_ID' and GROUPTABLE_ID=new.name_id)) then
      insert into GROUP_DETAIL (GROUP_ID,PARENT_ID,GROUPTABLE_ID,GROUPTABLE) values (-11,0,new.name_id,'PARTS.NAME_ID');
      select membership from PR_MEMBERSHIPS('PARTS=' || new.part_id || ';PARTS.NAME_ID=' || new.name_id || ';PARTS.IZG_ID=' || new.izg_id ||';',ascii_char(13)||ascii_char(10)) into new.mmbsh;
    end

/*
if ((new.enddt is null) and (new.quant<=0.0001)) then
begin
new.enddt='now';
update parts set enddt='now' where id=new.part_id;
end
if (not(new.enddt is null) and (new.quant>0.0001)) then
begin
new.enddt=null;
update parts set enddt=NULL where id=new.part_id;
end
*/
select membership from PR_MEMBERSHIPS('PARTS=' || new.part_id || ';PARTS.NAME_ID=' || new.name_id || ';PARTS.IZG_ID=' || new.izg_id ||';',ascii_char(13)||ascii_char(10)) into new.mmbsh;
end^

SET TERM ; ^






INSERT INTO SP$WDICTS (PARENT_ID, CAPTION, DESCRIPTION, SID, STATUS, INSERTDT, INI, SORTING, FRAMECLASS)
                         VALUES (0, 'Технологическая карта', 'Технологическая карта', 'CENNDETAIL                     ', 1, NULL, '[insertsql]
insert into DOPINFOCENN(id,description_id,name_id) values (:id,:description_id,:tek_id)

[deletesql_selected]
delete from DOPINFOCENN where id in (:selected_ids:)

[deletesql]
delete from DOPINFOCENN where id=:id

[refreshsql]
select * from VW_DOPINFOCENN where id=:id order by id

[selectsqlwithdeleted]

[selectsql]
select * from VW_DOPINFOCENN where name_id=:tek_id order by id

[main]
sourcetablename=DOPINFOCENN
returnfieldname=ID
captionfieldname=ID
keyfieldname=ID
ViewID=DOPINFOCENN
RootGroupTableName=
ShowCaption=Технологическая карта
GetCaption=Технологическая карта
GroupSelect=0
foldergroup=
initfolder_id=
dataset=0
InitTMSGroup_id=0
folders_visible=0
hidetoppanel=0

[cfSelect]
selectfieldexpression=caption
AllwaysPartial=1

[form_show]
position=4
left=0
Top=0
Width=800
Height=800
MaxWidth=0
MaxHeight=0
MinWidth=0
MinHeight=0

[form_get]
position=4
left=0
Top=0
Width=800
Height=600
MaxWidth=0
MaxHeight=0
MinWidth=0
MinHeight=0

[childs]
bottomdock_units=0
bottomdock_size=0
rightdock_units=0
rightdock_size=0

[edditfields]

[TMS_0]
group_id=73
caption=Скопировать ингредиенты у блюда

[TMS_1]
group_id=74
caption=Инициализация

[editfields]
DESCRIPTION_ID=WDICTS.DESCRIPTION
SDESCRIPTION=DESCRIPTION_ID
VALS=default
EDIZM=WDICTS.EDIZM
SEDIZM=EDIZM
BRUTTO=default
NETTO=default

[addfields]
DESCRIPTION_ID=WDICTS.DESCRIPTION
ID=select gen_id(gen_dopinfocenn_id,1) from rdb$database

', NULL, NULL)
                       ;
INSERT INTO SP$WDICTS (PARENT_ID, CAPTION, DESCRIPTION, SID, STATUS, INSERTDT, INI, SORTING, FRAMECLASS)
                         VALUES (0, 'Ингредиенты', 'Ингредиенты', 'DESCRIPTION                    ', 1, NULL, '[insertsql]

[deletesql_selected]

[deletesql]

[refreshsql]
select * from vals where id=:id and isactual=1

[selectsqlwithdeleted]
select * from vals where vtype=0 and isactual=1

[selectsql]
select * from vals where vtype=0 and isactual=1 order by svalue,id

[form_show]
position=8
left=0
Top=0
Width=600
Height=400
MaxWidth=0
MaxHeight=0
MinWidth=0
MinHeight=0

[form_get]
position=8
left=0
Top=0
Width=600
Height=600
MaxWidth=0
MaxHeight=0
MinWidth=0
MinHeight=0

[main]
sourcetablename=VALS
returnfieldname=ID
captionfieldname=ID
keyfieldname=ID
ViewID=SNAME_VALS
RootGroupTableName=
ShowCaption=Ингредиенты
GetCaption=Ингредиенты
GroupSelect=0
foldergroup=
initfolder_id=
dataset=0
hidetoppanel=0
InitTMSGroupid=75

[cfSelect]
selectfieldexpression=svalue
AllwaysPartial=1

[childs]
bottomdock_units=2
bottomdock_size=50
rightdock_units=0
rightdock_size=0

[TMS_0]
group_id=75
Caption=инициализация

', NULL, NULL)
                       ;
INSERT INTO SP$WDICTS (PARENT_ID, CAPTION, DESCRIPTION, SID, STATUS, INSERTDT, INI, SORTING, FRAMECLASS)
                         VALUES (0, 'Единицы', 'Единицы', 'EDIZM                          ', 1, NULL, '[insertsql]
insert into vals(id,svalue,vtype,isactual) values (:id,:svalue,7,1)

[deletesql_selected]

[deletesql]
update vals set isactual=0 where id=:id

[refreshsql]
select * from vals where id=:id

[selectsqlwithdeleted]
select * from vals where vtype=7

[selectsql]
select * from vals where vtype=7 and isactual=1 order by svalue,id

[form_show]
position=8
left=0
Top=0
Width=200
Height=200
MaxWidth=0
MaxHeight=0
MinWidth=0
MinHeight=0

[form_get]
position=8
left=0
Top=0
Width=200
Height=200
MaxWidth=0
MaxHeight=0
MinWidth=0
MinHeight=0

[main]
sourcetablename=vals
returnfieldname=ID
captionfieldname=ID
keyfieldname=ID
ViewID=VALS_EDIZM
RootGroupTableName=
ShowCaption=Един. измеренения
GetCaption=Един. измеренения
GroupSelect=0
foldergroup=
initfolder_id=
dataset=0
hidetoppanel=1

[cfSelect]
selectfieldexpression=svalue
AllwaysPartial=1

[childs]
bottomdock_units=2
bottomdock_size=50
rightdock_units=0
rightdock_size=0

[addfields]
ID=select gen_id(gen_vals_id,1) from rdb$database
svalue=default

', NULL, NULL)
                       ;
INSERT INTO SP$WDICTS (PARENT_ID, CAPTION, DESCRIPTION, SID, STATUS, INSERTDT, INI, SORTING, FRAMECLASS)
                         VALUES (0, 'Заполнить карту с блюда', 'Заполнить карту с блюда', 'WAREBASE                       ', 1, NULL, '[insertsql]

[deletesql_selected]

[deletesql]

[refreshsql]
select w.* from vw_warebase w  where w.name_id=:name_id and w.doc_type=21

[selectsqlwithdeleted]

[selectsql]
select w.* from vw_warebase w where w.doc_type=21 order by sname,name_id

[main]
sourcetablename=WAREBASE
returnfieldname=NAME_ID
captionfieldname=SNAME
keyfieldname=NAME_ID
ViewID=WAREBASE
RootGroupTableName=
ShowCaption=
GetCaption=
GroupSelect=0
foldergroup=
initfolder_id=
dataset=0
InitTMSGroup_id=0
folders_visible=0

[cfSelect]
selectfieldexpression=sname
AllwaysPartial=1

[form_show]
position=4
left=0
Top=0
Width=800
Height=800
MaxWidth=0
MaxHeight=0
MinWidth=0
MinHeight=0

[form_get]
position=8
left=0
Top=0
Width=200
Height=200
MaxWidth=0
MaxHeight=0
MinWidth=0
MinHeight=0

[childs]
bottomdock_units=2
bottomdock_size=70
rightdock_units=0
rightdock_size=0

[child_0]
caption=Подбор блюд
wdict=CENNDETAIL
oninit=tek_id=name_id,s=sname,mode=list
afterscroll=tek_id=name_id,s=sname,mode=list
onselectedchange=tek_id=name_id,s=sname
defaultdocksite=bottom
ShortCut=

', NULL, NULL)
                       ;
INSERT INTO SP$WDICTS (PARENT_ID, CAPTION, DESCRIPTION, SID, STATUS, INSERTDT, INI, SORTING, FRAMECLASS)
                         VALUES (0, 'Наименования товара', 'Наименование товара', 'NAME_WARE                      ', 1, NULL, '[insertsql]

[deletesql_selected]

[deletesql]

[refreshsql]
select * from WAREBASE where part_id=:part_id

[selectsqlwithdeleted]

[selectsql]
select * from WAREBASE where bcode_izg=:bcode order by sname,part_id

[main]
sourcetablename=WAREBASE
returnfieldname=part_id
captionfieldname=sname
keyfieldname=part_id
ViewID=WAREBASE
RootGroupTableName=
ShowCaption=Наименования
GetCaption=Наименования
GroupSelect=0
foldergroup=
initfolder_id=
dataset=0
InitTMSGroup_id=0
folders_visible=0

[cfSelect]
selectfieldexpression=sname
AllwaysPartial=1

[form_show]
position=4
left=0
Top=0
Width=800
Height=800
MaxWidth=0
MaxHeight=0
MinWidth=0
MinHeight=0

[form_get]
position=8
left=0
Top=0
Width=400
Height=200
MaxWidth=0
MaxHeight=0
MinWidth=0
MinHeight=0

[childs]
bottomdock_units=0
bottomdock_size=0
rightdock_units=0
rightdock_size=0', NULL, NULL)
                       ;

COMMIT WORK;

SET TERM ^ ;

create or alter procedure PR_DOC_RASHOD_COMMIT (
    DOC_ID type of DM_ID,
    DBG type of DM_STATUS)
as
declare variable PARENT_ID type of DM_ID;
declare variable PART_ID type of DM_ID;
declare variable PRICE type of DM_DOUBLE;
declare variable QUANT type of DM_DOUBLE;
declare variable DISCOUNT type of DM_DOUBLE;
declare variable SUMMA type of DM_DOUBLE;
declare variable SUMMA_O type of DM_DOUBLE;
declare variable SUM_NDSO type of DM_DOUBLE;
declare variable SUM_NDSR DM_DOUBLE;
declare variable NAC type of DM_DOUBLE;
declare variable DOC_COMMITDATE type of DM_DATE;
declare variable HUMAN_QUANT type of DM_TEXT;
declare variable SUM_DSC type of DM_DOUBLE;
declare variable DCARD type of DM_TEXT;
declare variable ACTIVE_ID type of DM_ID;
declare variable PART_TYPE DM_STATUS;
declare variable BASE_AGENT_ID DM_ID;
declare variable MAKE_ID DM_ID_NULL;
begin
  if ((select dt.base_type from docs d left join doc_types dt on dt.id=d.doc_type where d.id=:doc_id)=2) then
   execute procedure pr_rashod_ing_1(:doc_id);

  select cast(commitdate as date) from docs where id=:doc_id into :doc_commitdate;
  for select PARENT_ID,DOC_ID,PART_ID,PRICE,QUANT,DISCOUNT,SUMMA,summa_o, sum_ndso,SUM_NDSR, nac, human_quant, SUM_DSC, dcard, part_type, id, make_id
      from doc_detail_active where doc_id=:doc_id into :PARENT_ID,:DOC_ID,:PART_ID,:PRICE,:QUANT,:DISCOUNT,:SUMMA,:summa_o, :sum_ndso,:SUM_NDSR, :nac, :human_quant, :SUM_DSC, :dcard, :part_type, :active_id, :make_id
  do
    execute procedure PR_DOC_DETAIL_INSERT(:PARENT_ID,:DOC_ID,:PART_ID,QUANT,:DISCOUNT,:SUMMA,:summa_o, :price,:sum_ndso,:SUM_NDSR, :nac, :doc_commitdate, :human_quant, :SUM_DSC,:dcard,:active_id,:part_type,:make_id);
end^

SET TERM ; ^

/* Following GRANT statements are generated automatically */

GRANT SELECT ON DOCS TO PROCEDURE PR_DOC_RASHOD_COMMIT;
GRANT SELECT ON DOC_TYPES TO PROCEDURE PR_DOC_RASHOD_COMMIT;
GRANT EXECUTE ON PROCEDURE PR_RASHOD_ING_1 TO PROCEDURE PR_DOC_RASHOD_COMMIT;
GRANT SELECT ON DOC_DETAIL_ACTIVE TO PROCEDURE PR_DOC_RASHOD_COMMIT;
GRANT EXECUTE ON PROCEDURE PR_DOC_DETAIL_INSERT TO PROCEDURE PR_DOC_RASHOD_COMMIT;

/* Existing privileges on this procedure */

GRANT EXECUTE ON PROCEDURE PR_DOC_RASHOD_COMMIT TO PROCEDURE PR_DOC_COMMIT;
GRANT EXECUTE ON PROCEDURE PR_DOC_RASHOD_COMMIT TO "PUBLIC";
GRANT EXECUTE ON PROCEDURE PR_DOC_RASHOD_COMMIT TO STANDART;
GRANT EXECUTE ON PROCEDURE PR_DOC_RASHOD_COMMIT TO SYSDBA;