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)
		($g.d_vehicle@retrieve)"
}
{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"
{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=vehicle.id_vehicle   border = box
       left=80    top=33    height=20      width=60 
       alias=id_vehicle         font_size=12   font_family=0    bg_color="#ffffff"
       editable=handbook
       edit="opennew find_TC.rml "
       editexp="(id_vehicle=STORE.vehicle.id_vehicle)"
       dep="name_of_models"
   }
   {field
       target=models_of_vehicle.name_of_models   border = box
       left=145    top=33    height=20      width=100
       alias=name_of_models         font_size=12   font_family=0    bg_color="#ffffff"
       editable=readonly
       editexp="(name_of_models=STORE.models_of_vehicle.name_of_models)"
   }
//   {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 find_TC.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"
   }
   {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.parent_id_head,
//                        head.id_client1,head.id_client2,
//                        head.id_department1,head.id_department2,
//                        vehicle.id_head2,vehicle.id_active,active.name_active,
//                        vehicle.id_vehicle, models_of_vehicle.name_of_models
//                   from head,personal,vehicle,active,models_of_vehicle
//                  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_head = vehicle.id_head2
//                   and vehicle.id_active = active.id_active (+)
//                   and head.id_type_doc = 91
//                   and vehicle.id_models_of_vehicle = models_of_vehicle.id_models_of_vehicle"
//              editable = yes
//                  head = yes
//                unique = "('head','head.id_head')"
//               default = "head.id_head=~ds.hpk~,head.id_type_doc=~91~,
//                          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~"
  {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,
			active.id_active,active.name_active,
			vehicle.id_vehicle, models_of_vehicle.name_of_models
                   from head,personal,active,vehicle, models_of_vehicle
                  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 = 91
		   and vehicle.id_active = active.id_active 
		   and vehicle.id_head2 = head.id_head
		   and vehicle.id_models_of_vehicle=models_of_vehicle.id_models_of_vehicle(+)"
              editable = yes
                  head = yes
                unique = "('head','head.id_head')"
               default = "head.id_head=~ds.hpk~,head.id_type_doc=~91~,
                          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~"
{datastore 
      alias = d_vehicle
      query = "select vehicle.id_head2, vehicle.id_vehicle
               from vehicle
               where vehicle.id_head2 = ~($try (d_head.head.id_head) $catch ('NullException') (-1) )~"
             editable = yes
               unique = "('vehicle','vehicle.id_vehicle')" 
              default = "vehicle.id_head2=~($try (d_head.head.id_head) $catch ('NullException') (0) )~,
			 vehicle.operation=~0~"
    } // end ds
} // ds

} // form
} // scroll
{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)
                            )
                        )
			($if (global.create = 1)
				($g.self@doAction 'execute exec update vehicle set id_head2 = ' + ($try ($g.d_head@getValue 'HEAD.ID_HEAD') $catch ('Any')('')) + ' where id_vehicle = ' + ($try ($g.d_head@getValue 'VEHICLE.ID_VEHICLE') $catch ('Any')('')) + ';')
			)
                        ($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)
                )
            )
	    ($if (global.create = 1)
		($g.self@doAction 'execute exec update vehicle set id_head2 = ' + ($try ($g.d_head@getValue 'HEAD.ID_HEAD') $catch ('Any')('')) + ' where id_vehicle = ' + ($try ($g.d_head@getValue 'VEHICLE.ID_VEHICLE') $catch ('Any')('')) + ';')
	    )
            ($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

