Cp1251
doc
document_title="История перемещений актива"
document_width=1300
document_height=500

postloadscript = "($X
                     ($debug 'ARGUMENTS.0: ' + ARGUMENTS.0 + ' (' + ($ARGUMENTS.0@type) + ')')
                     ($debug 'ARGUMENTS.1: ' + ARGUMENTS.1 + ' (' + ($ARGUMENTS.1@type) + ')')
                     ($debug 'substr 0 10: [' + ($ARGUMENTS.1@substr 0 10) + ']')
                     ($ret '')
                  )"


{ toolbar BACKGROUND=LIGHTGRAY
{grid
buttonbar_font_family = 0     buttonbar_font_size = 12
buttonbar_size = 30           titlebar_size = 18          titlebar_height = 40
rowsize = 20                  editable = no
return = no
edit = "open docs/sklad.rml ~($g.ds@getValue 'id_head')~"

{column size=50  
   title="ID"   
   target=id_active  title_font_family=2   halignment=left
   font_color="#000000"    font_size=12            font_family=0
   editmask = "##0."
   visible = no
}
{column size=180  
   title="Название"   
   target=name_active  title_font_family=2   halignment=left
   font_color="#000000"    font_size=12            font_family=0
}
{column size=150  
   title="На замену"   
   target=name_active_replace  title_font_family=2   halignment=left
   font_color="#000000"    font_size=12            font_family=0
}
{column size=80  
   title="Документ"   
   target=num_sd  title_font_family=2   halignment=left
   font_color="#000000"    font_size=12            font_family=0
}
{column size=80  
   title="Основание"   
   target=parent_num_sd  title_font_family=2   halignment=left
   font_color="#000000"    font_size=12            font_family=0
}
{column size=70  
   title="Дата док."   
   target=date_sd  title_font_family=2   halignment=center
   font_color="#000000"    font_size=12            font_family=0
}
{column size=100  
   title="<html>Перемещено в<br>производство на</html>"   
   target=date1  title_font_family=2   halignment=center
   font_color="#000000"    font_size=12            font_family=0
}
{column size=120  
   title="Со склада"   
   target=dep1_name1_dep  title_font_family=2   halignment=left
   font_color="#000000"    font_size=12            font_family=0
}
{column size=180  
   title="на склад"   
   target=dep2_name1_dep  title_font_family=2   halignment=left
   font_color="#000000"    font_size=12            font_family=0
}
{column size=80  
   title="Кол-во"   
   target=q1_spc  title_font_family=2   halignment=right
   font_color="#000000"    font_size=12            font_family=0
   editmask = "# #0.000"
}
{column size=50  
   title="в пр-во"   
   target=contract  title_font_family=2   halignment=right
   font_color="#000000"    font_size=12            font_family=0
   editmask = "# #0.000"
}
{column size=200  
   title="Примечание"   
   target=comment_spc  title_font_family=2   halignment=right
   font_color="#000000"    font_size=12            font_family=0
   editmask = "# #0.000"
}

{datastore 
 alias = ds
 query = "select id_head, num_sd, parent_num_sd, date_sd, date1, q1_spc, dep1_name1_dep, dep2_name1_dep,
                 id_active, name_active, name_active_replace, comment_spc, contract
            from (
          select head.id_head, head.num_sd, 
                 -- дата родительского документа, если он есть
                 (select date_sd from head h where h.id_head = nvl(head.parent_id_head, head.id_head)) date_sd,
                 util.parent_doc(head.id_head) parent_num_sd,
                 decode(nvl(head.id_contract, 0), 0, to_char(null), to_char(head.date1, 'Month YYYY')) date1,
                 spc.q1_spc, spc.comments comment_spc,
                 dep1.name1_dep dep1_name1_dep, dep2.name1_dep dep2_name1_dep,
                 active.id_active, active.name_active, active_replace.name_active name_active_replace,
                 case when nvl(head.id_contract, 0) = 0
                   then null
                   else 'да' 
                 end contract
            from head, spc, department dep1, department dep2,
                 (
                   select id_active, name_active
                     from active
                    where id_active = ~($try (ARGUMENTS.0) $catch ('NullException') (1) )~
                          or
                          analog_id = ~($try (ARGUMENTS.0) $catch ('NullException') (1) )~
                 ) active, active active_replace
           where spc.id_active = active.id_active
             and spc.id_head = head.id_head
             and spc.parent_id_spc = active_replace.id_active(+)
             and head.id_type_doc = 96
             and head.accept = 1
             --and head.id_contract = 1
             --and head.date1 between to_date('~($ARGUMENTS.1@substr 0 10)~', 'YYYY-MM-DD')
             --                   and last_day(to_date('~($ARGUMENTS.1@substr 0 10)~', 'YYYY-MM-DD'))
             and head.date1 >= to_date('~($ARGUMENTS.1@substr 0 10)~', 'YYYY-MM-DD')
             and head.id_department1 = dep1.id_department (+)
             and head.id_department2 = dep2.id_department (+)
                 )
           order by date_sd desc"
        editable = no
}
}

{button
    left = 72  width = 50    height = 20
    BACKGROUND = "LIGHTGRAY"    foreground="#000000"
    label="Выход ESC"
   action="($self@actdok)"
   ShortCut = "Escape"
  }
} // toolbar


