Cp1251
doc
document_title="История заявок на выдачу материалов"
document_width=1300
document_height=800

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=150  
   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=70  
   title="Дата док."   
   target=date_sd  title_font_family=2   halignment=center
   font_color="#000000"    font_size=12            font_family=0
}
{column size=150  
   title="Продукция"   
   target=name_active_prod  title_font_family=2   halignment=left
   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=center
   font_color="#000000"    font_size=12            font_family=0
}
{column size=90  
   title="<html>Кол-во<br>для пр-ва"   
   target=q1_spc  title_font_family=2   halignment=right
   font_color="#000000"    font_size=12            font_family=0
   editmask = "# #0.000"
}
{column size=90  
   title="Выдать в цех"   
   target=q2_spc  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, date_sd, date1, q1_spc, q2_spc, dep1_name1_dep,
                 id_active, name_active, name_active_replace, name_active_prod, comment_spc
            from (
          select head.id_head, head.num_sd, head.date_sd, 
                 decode(nvl(head.id_contract, 0), 0, to_char(null), to_char(head.date1, 'Month YYYY')) date1,
                 spc.q1_spc, spc.q2_spc, spc.comments comment_spc,
                 dep1.name1_dep dep1_name1_dep,
                 active.id_active, active.name_active, active_replace.name_active name_active_replace,
                 active_prod.name_active name_active_prod
            from head, spc, department dep1,
                 (
                   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, active active_prod
           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 = 17
             --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 trunc(head.date1, 'month') = trunc(to_date('~($ARGUMENTS.1@substr 0 10)~', 'YYYY-MM-DD'), 'month')
             and head.id_department1 = dep1.id_department (+)
             and spc.id_department = active_prod.id_active (+)
                 )
           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


