Cp1251
DOC 
foreground = lightgray
document_width = 750
document_height = 550
document_title = "Документы по ОС"
style = "style/docs.st"
preloadscript="
(global.create = 0)
(global.d1 = ('\''+'01.01.2003'+'\'') )
(global.get_num = 0)
"
{dscollection
   alias = ds
   initQuery = "select head_sq.nextval,sysdate,id_personal from personal where upper(login)=user"
   aliases = "hpk,date,idp"
   seqquery = "select doc_vehicle_sq.nextval from dual"
   seqnames = "spk"
   initAction ="(global.create = 1)
                (global.get_num = 1)"
}
{datastore  alias=doc_num
    query="select num_sd from (select 'ДокОС-'||(nvl(max(to_number(substr(num_sd, 7))), 0) + 1) num_sd
             from head
            where head.num_sd like 'ДокОС-%')"
  } // end of ds

{toolbar   BACKGROUND = "LIGHTGRAY"
{splitpanel   percent=40
{scrollpane 
{form width=780 height=100       bg_color="#c0c0c0"   alias = fm
   {label
       value="N док."       
       left=11    top=8     height=20       width=40
       font_size=12         font_family=0   bg_color="#c0c0c0"
   }  
   {field
       target=head.num_sd   border = box
       left=55     top=8    height=20       width=95
       alias=num_sd         font_size=12    font_family=0    bg_color="#ffffff"
       editable=readonly
   }  
   {label
       value="Дата док."    
       left=155    top=8    height=20       width=50
       font_size=12         font_family=0   bg_color="#c0c0c0"
   }
   {field
       target=head.date_sd  border = box
       left=210    top=8    height=20       width=70
       alias=date_sd        font_size=12    font_family=0    bg_color="#ffffff"
       dep="ficd1"
   }
 {field 
   type = string
   left = 500  width = 70 height=25    
   alias=ficd1           visible=no
   exp="(ficd1 = global.d1)"
  }
   {field
       target=head.accept    border = box   visible=no
       left=200   top=83    height=20      width=40
       alias=accept         font_size=12    font_family=0    bg_color="#ffffff"
   }
   {label
       value="Исполнитель"  
       left=420  top=8      height=20       width=70
       font_size=12         font_family=0   bg_color="#c0c0c0"
   }
   {field
       target=personal.fname                border = box
       left=505    top=8    height=20       width=70
       alias=name           font_size=12    font_family=0    bg_color="#ffffff"
       editable = readonly
   }     
   {label
       value="ТС"    
       left=11    top=33     height=20      width=65
       font_size=12          font_family=0  bg_color="#c0c0c0"
   }
   {field
       target=head.parent_id_head   border = box
       left=80    top=33    height=20      width=100   visible=no
       alias=parent_id_head         font_size=12   font_family=0    bg_color="#ffffff"
        editable = readonly
       editexp="(parent_id_head=STORE.head.id_head)"
   }
   {field
       target=active.name_active   border = box
       left=80    top=33    height=20      width=100
       alias=name_act         font_size=12   font_family=0    bg_color="#ffffff"
       editable=handbook
       edit="opennew act_vehicle.rml "
       editexp="(name_act=STORE.active.name_active)"
       dep="parent_id_head"
   }
   {label
       value="Примечание"    
       left=11    top=58     height=20      width=65
       font_size=12          font_family=0  bg_color="#c0c0c0"
   }
   {field
       target=head.comment_sd   border = box
       left=80    top=58    height=20      width=495
       alias=comment_sd         font_size=12   font_family=0    bg_color="#ffffff"
   }
   {datastore 
        alias = d_head
        query = "select head.id_head,head.id_type_doc,head.accept,
                        head.num_sd,head.date_sd,head.comment_sd,
                        head.id_personal,personal.fname,head.parent_id_head,
                        head.id_client1,head.id_client2,
                        head.id_department1,head.id_department2,
                        vehicle.id_head,vehicle.id_active,active.name_active
                   from head,personal,vehicle,active
                  where head.id_head = ~($try ($if (global.create == 0)
                                                (ARGUMENTS.0)
                                               $else (ds.hpk))
                                         $catch ('any') (-1))~
                   and head.id_personal = personal.id_personal
		   and head.parent_id_head = vehicle.id_head (+)
		   and vehicle.id_active = active.id_active (+)
                   and head.id_type_doc = 92"
              editable = yes
                  head = yes
                unique = "('head','head.id_head')"
               default = "head.id_head=~ds.hpk~,head.id_type_doc=~92~,
                          head.date_sd=~ds.date~,
                          head.id_personal=~ds.idp~,
                          head.accept=~0~,
                          head.num_sd=~'ДокОС-'~,
                          head.id_client1=~1~,head.id_client2=~1~,
                          head.id_department1=~0~,head.id_department2=~0~"
} // ds
} // form
} // scroll
{tabset labels = "перечень документов"
 tabs_on_top=yes
{grid
editable = yes
alias = GRIDSPC
add="opennew document_vehicle.rml"
buttonbar_font_family=0       buttonbar_font_size=12           
buttonbar_size = 30           titlebar_size = 18            rowsize=20 
addexp="id_doc=store.document_vehicle.id_document_vehicle;
        name_doc=store.document_vehicle.name_doc"
{menu
   {item label = "Добавить документ" action="opennew document_vehicle.rml"}
}

    
 {column size=40  
     visible=no
     title="Номер"   
     target=doc_vehicle.id_doc_vehicle        title_font_family=2     halignment=left
     font_color="#000000"     font_size=12              font_family=0
 }
 {column size=110 
    visible=no
    title="Номер"   
    target=doc_vehicle.id_head        title_font_family=2
    font_color="#000000"      font_size = 12            font_family=0
 }
 {column size=40
    title="Код"              font_family=0           editable = readonly 
    target=doc_vehicle.id_document_vehicle     title_font_family=2     halignment=left
    alias=id_doc                font_color="#000000"     font_size=12    visible=no
    editexp = "id_doc=STORE.document_vehicle.id_document_vehicle"
 }
 {column size=180       title="Наименование"
    target=document_vehicle.name_doc  title_font_family=2     halignment=left
    font_color="#000000"      font_size=12              font_family=0
    alias=name_doc             
    editable = handbook     
    edit = "opennew document_vehicle.rml"
    editexp = "name_doc=STORE.document_vehicle.name_doc"
    dep = "id_doc"

 }
 {column size=100       title="Начал. дата" 
    target=doc_vehicle.date_begin      title_font_family=2      halignment=right
    font_color="#000000"     font_size=12            font_family=0
    alias = b_date
 }
 {column size=100       title="Кон. дата" 
    target=doc_vehicle.date_end      title_font_family=2      halignment=right
    font_color="#000000"     font_size=12            font_family=0
    alias = e_date
 }
 {datastore 
      alias = doc_vehicle
      query = "select doc_vehicle.id_doc_vehicle,doc_vehicle.id_head,
		      doc_vehicle.date_begin,doc_vehicle.date_end,
		      doc_vehicle.id_document_vehicle,document_vehicle.name_doc
                 from doc_vehicle,document_vehicle
                where doc_vehicle.id_head = ~($try (d_head.head.id_head) $catch ('NullException') (-1) )~ 
                  and doc_vehicle.id_document_vehicle = document_vehicle.id_document_vehicle "
             editable = yes
               unique = "('doc_vehicle','doc_vehicle.id_doc_vehicle')" 
              default = "doc_vehicle.id_head=~($try (d_head.head.id_head) $catch ('NullException') (-1) )~,
                         doc_vehicle.id_doc_vehicle=~ds.spk~,
			 doc_vehicle.date_begin=~ds.date~,
			 doc_vehicle.date_end=~ds.date~"  
} // ds
} // grid1
} // tabset
} // split
{button
  left = 11  width = 50    height = 20
  BACKGROUND = "LIGHTGRAY"    foreground="#000000"
  label = "Сохранить и выйти F3"
  action = "($X
             (tmp = 'Вы действительно хотите сохранить все изменения и выйти' + '')
             (m = ($g.self@sure tmp 0))
               ($if (m == 0)()
               $else 
                    (
                        ($if (global.get_num == 1)
                            (
                                ($g.doc_num@retrieve)
                                d_head.head.num_sd = ($try ($g.doc_num@GetValue 'NUM_SD') $catch ('Any')(''))
                                g.num_sd = ($try ($g.doc_num@GetValue 'NUM_SD') $catch ('Any')(''))
                                (global.get_num = 0)
                            )
                        )
                        ($g.self@actdok)
                    )
               )
             ($ret ''))"
  shortcut = "F3"
}
{button
  left = 11  width = 50    height = 20
  BACKGROUND = "LIGHTGRAY"    foreground="#000000"
  label = "Запис F4"
  action = "($if (global.get_num == 1)
                (
                    ($g.doc_num@retrieve)
                    d_head.head.num_sd = ($try ($g.doc_num@GetValue 'NUM_SD') $catch ('Any')(''))
                    g.num_sd = ($try ($g.doc_num@GetValue 'NUM_SD') $catch ('Any')(''))
                    (global.get_num = 0)
                )
            )
            ($g.self@actsave)"
  shortcut = "F4"
}
{button
  left = 72  width = 50    height = 20
  BACKGROUND = "LIGHTGRAY"    foreground="#000000"
  label = "Отмена ESC"
  action = "($X
             (tmp = 'Вы действительно хотите выйти без сохранения данных' + '')
             (m = ($g.self@sure tmp 0))
               ($if (m == 0)()
               $else ($g.self@actcancel)
               )
             ($ret ''))"
  shortcut = "escape"
}
} // toolbar

