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)
"
postloadscript="($X
	 	 ($IF (($g.D_HEAD@getvalue 'HEAD.ACCEPT') == 1)
		  ($g.progress@setValue 'Только для чтения')
		 )
		($ret ''))"
{dscollection
   alias = ds
   initQuery = "select head_sq.nextval,sysdate,id_personal from personal where upper(login)=user"
   aliases = "hpk,date,idp"
   initAction ="(global.create = 1)
                (global.get_num = 1)
                ($X ($G.substore@retrieve)
                    ($if (($G.substore@size) !=0)
		      (
		        (t = ($g.substore@iterator))
                        (i = 0)
		        ($while ($t@next)
                            (
                                (i += 1)
                                ($g.substore@SetCurRow (i-1))
			        ($G.d_vehicle@newrow)
				 (tmp = ($try ($g.substore@getvalue 'ACTIVE.ID_ACTIVE') $catch ('NullException')(0)))
				 ($G.d_vehicle@setvalue 'VEHICLE.ID_ACTIVE' tmp)
				 (tmp = ($try ($g.substore@getvalue 'ACTIVE.NAME_ACTIVE') $catch ('NullException')(' ')))
				 ($G.d_vehicle@setvalue 'ACTIVE.NAME_ACTIVE' tmp)
			     )
			 )
		      )
                    )    
                ($G.d_vehicle@notifyviews)
                ($ret 1)
                )"
   seqquery = "select vehicle_sq.nextval from dual"
   seqnames = "vpk"
}
{datastore  alias=doc_num
    query="select num_sd from (select 'ВвОС-'||(nvl(max(to_number(substr(num_sd, 6))), 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=60       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=430  top=8      height=20       width=70
       font_size=12         font_family=0   bg_color="#c0c0c0"
   }
   {field
       target=personal.fname                border = box
       left=510    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.comment_sd   border = box
       left=80    top=33    height=20      width=495
       alias=comment_sd         font_size=12   font_family=0    bg_color="#ffffff"
   }
   {label
    alias=progress
    left = 630  top = 8      width = 150     height = 20 
    font_size=16              font_family=2   font_color="#000088"
    bg_color="#c0c0c0"        border=none     
   }

{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.id_client1,head.id_client2,
                        head.id_department1,head.id_department2
                   from head,personal
                  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.id_type_doc = 90"
              editable = yes
                  head = yes
                unique = "('head','head.id_head')"
               default = "head.id_head=~ds.hpk~,head.id_type_doc=~90~,
                          head.date_sd=~ds.date~,
                          head.id_personal=~ds.idp~,
                          head.id_vehicle=~ds.vpk~,
                          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
add="opennew find_choose_os.rml"
alias = GRIDSPC
buttonbar_font_family=0       buttonbar_font_size=12           
buttonbar_size = 30           titlebar_size = 18            rowsize=20
addexp="war1=store.active.id_active;
        name_w=store.active.name_active;"
{menu
   {item label = "Поиск в справочнике" action="opennew find_choose_os.rml"}
}
{column size=70
    title="Код актива"              font_family=0       visible=no
    target=vehicle.id_active     title_font_family=2     halignment=left
    font_color="#000000"    font_size=12   
    alias=war1
 }
 {column size=60  
     title="Код ТС"   
     target=vehicle.id_vehicle        title_font_family=2     halignment=left
     font_color="#000000"     font_size=12              font_family=0
     editable = readonly 
 }
 
 {column size=70
    title="Актив"              font_family=0       
    target=active.name_active     title_font_family=2     halignment=left
    font_color="#000000"    font_size=12 
    alias=name_w
 }
 {column size=80       title="Модель"
    target=vehicle.id_models_of_vehicle    visible=no
    title_font_family=2     halignment=left
    font_color="#000000"      font_size=12              font_family=0
    alias=id_models_of_vehicle  
    editexp="id_models_of_vehicle=STORE.models_of_vehicle.id_models_of_vehicle"
 }
 {column size=80       title="Модель"
    target=models_of_vehicle.name_of_models     alias=name_of_models
    title_font_family=2     halignment=left
    font_color="#000000"      font_size=12              font_family=0
    editable=handbook
    edit="opennew find_models.rml"
    editexp="name_of_models=STORE.models_of_vehicle.name_of_models"
    dep="name_of_models,id_models_of_vehicle"    
    
 }
 {column size=80       title="VIN"
    target=vehicle.vin
    title_font_family=2     halignment=left
    font_color="#000000"      font_size=12              font_family=0
 }
 {column size=110       title="Государственный N"
    target=vehicle.state_number
    title_font_family=2     halignment=left
    font_color="#000000"      font_size=12              font_family=0
 }
 {column size=70       title="Год выпуска"
    target=vehicle.year_release
    title_font_family=2     halignment=left
    font_color="#000000"      font_size=12              font_family=0
 }
 {column size=80       title="N кузова"
    target=vehicle.number_body
    title_font_family=2     halignment=left
    font_color="#000000"      font_size=12              font_family=0
 }
 {column size=70       title="Цвет кузова"
    target=vehicle.color_body
    title_font_family=2     halignment=left
    font_color="#000000"      font_size=12              font_family=0
 }
 {column size=80       title="N двигателя"
    target=vehicle.number_engine
    title_font_family=2     halignment=left
    font_color="#000000"      font_size=12              font_family=0
 }
 {column size=100       title="Модель двигателя"
    target=vehicle.model_engine
    title_font_family=2     halignment=left
    font_color="#000000"      font_size=12              font_family=0
 }
 {column size=150       title="Показ спидометра (в начале)"
    target=vehicle.track_vehicle
    title_font_family=2     halignment=left
    font_color="#000000"      font_size=12              font_family=0
 }
 {column size=50       title="ТО1"
    target=vehicle.to1
    title_font_family=2     halignment=left
    font_color="#000000"      font_size=12              font_family=0
 }
 {column size=50       title="ТО2"
    target=vehicle.to2
    title_font_family=2     halignment=left
    font_color="#000000"      font_size=12              font_family=0
 }
 {column size=110       title="Пробег между сл ТО"
    target=vehicle.delta_to
    title_font_family=2     halignment=left
    font_color="#000000"      font_size=12              font_family=0
 }
 {column size=60       title="Статус ТС"
    target=vehicle.status_vehicle
    title_font_family=2     halignment=left
    font_color="#000000"      font_size=12              font_family=0
    visible=no
 }
 {column size=60             visible=no
    target = nds.proc_nds            title="НДС"      title_font_family=2
    font_color="#000000"     font_size=12            font_family=0
    editmask = "# #0"    alias = pr_nds        halignment=right
    editable = readonly
 }
 {datastore 
      alias = d_vehicle
      query = "select vehicle.id_vehicle, vehicle.id_models_of_vehicle, 
                      vehicle.id_active, active.name_active,vehicle.vin, vehicle.number_body, 
                      vehicle.number_engine, vehicle.model_engine, 
                      vehicle.state_number, vehicle.to1, vehicle.to2, 
                      vehicle.id_qualif_unit_measur,vehicle.operation, 
                      vehicle.track_vehicle, vehicle.status_vehicle, 
                      vehicle.color_body, vehicle.year_release,
                      vehicle.delta_to,nds.proc_nds,
                      models_of_vehicle.name_of_models,vehicle.id_head
               from vehicle,nds,models_of_vehicle,active
               where vehicle.id_head = ~($try (d_head.head.id_head) $catch ('NullException') (-1) )~ 
               and active.id_nds = nds.id_nds
               and vehicle.id_active = active.id_active 
               and vehicle.id_models_of_vehicle=models_of_vehicle.id_models_of_vehicle(+)"
             editable = yes
               unique = "('vehicle','vehicle.id_vehicle')" 
              default = "vehicle.id_vehicle=~ds.vpk~,
			 vehicle.id_head=~($try (d_head.head.id_head) $catch ('NullException') (0) )~,
			 vehicle.operation=~0~"
//        {datastore
//            alias = substore
//            query = "select active.id_active,active.name_active
//                     from active
//                     where active.id_active=~($try (ARGUMENTS.0) $catch ('NullException') (0) )~"
//        }
	{datastore
            alias = substore
            query = "select active.id_active,active.name_active
                     from spc, active
                     where spc.id_head=~($try (ARGUMENTS.0) $catch ('NullException') (0) )~
		     and spc.id_active = active.id_active"
        }
} // ds
} // grid1
} // tabset
} // split
{button
  left = 11  width = 50    height = 20
  BACKGROUND = "LIGHTGRAY"    foreground="#000000"
  label = "Сохранить и выйти F3"
  action = "($X
	     ($if (($G.D_HEAD@getValue 'HEAD.ACCEPT') == 1)
		  (
		    ($g.self@actcancel)
		    ($ret '')
		  )
	     )
             (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 (($G.D_HEAD@getValue 'HEAD.ACCEPT') == 1)
		  (
		    ($g.self@actcancel)
		    ($ret '')
		  )
	     )
	    ($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

