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)
(global.cur_id_active = -1)"

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 ="($X
                (global.create = 1)
                (global.get_num = 1)
	    ($IF (($try (ARGUMENTS.0) $catch ('NullExeption') (-1)) == -1) 
		(($g.substore@retrieve)
		 ($IF (($G.substore@size) != 0)
		      ((tmp=($try ($g.substore@getvalue 'ID_AUTOMOBILE') $catch ('NullExeption') (-1)))
		       ($G.d_head@setvalue 'HEAD_AUTO.ID_AUTOMOBILE' tmp)
	  	       (tmp=($try ($g.substore@getvalue 'ID_MODELS_OF_VEHICLE') $catch ('NullExeption') (-1)))
		       ($G.d_head@setvalue 'AUTOMOBILE.ID_MODELS_OF_VEHICLE' tmp)
		       (tmp=($try ($g.substore@getvalue 'NAME_OF_MODELS') $catch ('NullExeption') ('')))
		       ($G.d_head@setvalue 'MODELS_OF_VEHICLE.NAME_OF_MODELS' tmp)
	               (tmp=($try ($g.substore@getvalue 'NUMBER_BODY') $catch ('NullExeption') ('')))
        	       ($G.d_head@setvalue 'AUTOMOBILE.NUMBER_BODY' tmp)
	               (tmp=($try ($g.substore@getvalue 'VIN') $catch ('NullExeption') ('')))
	               ($G.d_head@setvalue 'AUTOMOBILE.VIN' tmp)
		      ) 
		 )
		)
	    )
	      ($ELSE 
                ( ($G.substore2@retrieve)
		  ($g.substore@retrieve)
                  ($debug 'SUB RETRIEVE')
                  ($if (($G.substore2@size) != 0)(
                       (tmp = ($try ($g.substore2@getvalue 'HEAD.ID_CLIENT1') $catch ('NullException')(0)))
                       ($G.d_head@setvalue 'HEAD.ID_CLIENT1' tmp)
                       (tmp = ($try ($g.substore2@getvalue 'CLIENT.NAME1_CLIENT') $catch ('NullException')(' ')))
                       ($G.d_head@setvalue 'CLIENT.NAME1_CLIENT' tmp)
                       (tmp = ($try ($g.substore2@getvalue 'HEAD.ID_CLIENT2') $catch ('NullException')(0)))
                       ($G.d_head@setvalue 'HEAD.ID_CLIENT2' tmp)
                       (tmp = ($try ($g.substore2@getvalue 'CLIENT2.NAME1_CLIENT') $catch ('NullException')(' ')))
                       ($G.d_head@setvalue 'CLIENT2.NAME1_CLIENT' tmp)
                       (tmp = ($try ($g.substore2@getvalue 'HEAD.COMMENT_SD') $catch ('NullException')(' ')))
                       ($G.d_head@setvalue 'HEAD.COMMENT_SD' tmp)
                       (tmp = ($try ($g.substore2@getvalue 'HEAD.ID_HEAD') $catch ('NullException')(0)))
                       ($G.d_head@setvalue 'HEAD.PARENT_ID_HEAD' tmp)
                       (tmp = ($try ($g.substore2@getvalue 'HEAD.DATE_SD') $catch ('NullException')('')))
                       ($G.d_head@setvalue 'HEAD.DATE_SD' tmp)
                       (tmp = ($try ($g.substore2@getvalue 'HEAD_AUTO.DATE_END_SD') $catch ('NullException')('')))
                       ($G.d_head@setvalue 'HEAD_AUTO.DATE_END_SD' tmp)
                       (tmp = ($try ($g.substore2@getvalue 'HEAD_AUTO.ID_AUTOMOBILE') $catch ('NullException')(0)))
                       ($G.d_head@setvalue 'HEAD_AUTO.ID_AUTOMOBILE' tmp)
                       (tmp = ($try ($g.substore2@getvalue 'HEAD_AUTO.ID_TYPE') $catch ('NullException')(0)))
                       ($G.d_head@setvalue 'HEAD_AUTO.ID_TYPE' tmp)
                       (tmp = ($try ($g.substore2@getvalue 'TYPE_RENT.NAME_TYPE_RENT') $catch ('NullException')(0)))
                       ($G.d_head@setvalue 'TYPE_RENT.NAME_TYPE_RENT' tmp)
                       (tmp = ($try ($g.substore@getvalue 'ID_MODELS_OF_VEHICLE') $catch ('NullException')(0)))
                       ($G.d_head@setvalue 'AUTOMOBILE.ID_MODELS_OF_VEHICLE' tmp)
                       (tmp = ($try ($g.substore@getvalue 'NAME_OF_MODELS') $catch ('NullException')(0)))
                       ($G.d_head@setvalue 'MODELS_OF_VEHICLE.NAME_OF_MODELS' tmp)
                       (tmp=($try ($g.substore@getvalue 'NUMBER_BODY') $catch ('NullExeption') ('')))
                       ($G.d_head@setvalue 'AUTOMOBILE.NUMBER_BODY' tmp)
                       (tmp=($try ($g.substore@getvalue 'VIN') $catch ('NullExeption') ('')))
                       ($G.d_head@setvalue 'AUTOMOBILE.VIN' tmp)
                     )
                  ) 
		)
	      )
           ($ret 1))  "
}
   {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
   {datastore
        alias = substore2
        query = "select head.id_head,head.date_sd,head_auto.date_end_sd,
                        head.id_client1,head.id_client2,client.name1_client,client2.name1_client,
                        head.comment_sd,
			head_auto.id_automobile,
		        head_auto.id_type,type_rent.name_type_rent,
		        automobile.id_models_of_vehicle,models_of_vehicle.name_of_models,
                automobile.number_body, automobile.vin
                   from head,client,client client2,head_auto,automobile,models_of_vehicle,type_rent
                  where head.id_head = ~($try ($if (global.create == 1)
                                  	    	(ARGUMENTS.0)
	                                       $else (-1))
		                         $catch ('any') (-1))~
                    and head.id_client1 = client.id_client 
                    and head.id_client2 = client2.id_client 
   	            and head.id_head=head_auto.id_head
		    and head_auto.id_type = type_rent.id_type_rent
        	    and head_auto.id_automobile=automobile.id_automobile
		    and automobile.id_models_of_vehicle=models_of_vehicle.id_models_of_vehicle"
   }       
{datastore  alias=substore
    query="select id_models_of_vehicle,name_of_models,id_automobile,number_body,vin
      from(select models_of_vehicle.id_models_of_vehicle,
		  models_of_vehicle.name_of_models,
                  automobile.id_automobile,
                  automobile.number_body, automobile.vin
             from models_of_vehicle,automobile
            where automobile.id_models_of_vehicle = models_of_vehicle.id_models_of_vehicle
	      and automobile.id_automobile = ~($try (ARGUMENTS.1) $catch ('ANY') (-1))~ )
	  "
} // end of ds
// автомобиль введен в автопарк?
{datastore  alias=dial1
    query="select head.id_head
             from head,head_auto
            where head.id_head = head_auto.id_head
	      and head.accept = 1
	      and head.id_head <> ~($try ($g.d_head@GetValue 'HEAD.ID_HEAD') $catch ('Any')(-1))~
              and head_auto.id_automobile = ~($try ($g.d_head@GetValue 'HEAD_AUTO.ID_AUTOMOBILE') $catch ('Any')(-1))~
	      and head.date_sd <= '~($try ($($@date ($g.d_head@GetValue 'HEAD.DATE_SD') )@toPLString) $catch ('Any')(global.d1))~'
		 "
} // end of ds
// автомобиль выведен из автопарк?
{datastore  alias=dial2
    query="select head.id_head
	     from head
	    where head.id_type_doc = 72
	      and head.sort =
	   (select max(head.sort)
             from head,head_auto
            where head.id_head = head_auto.id_head
	      and head.accept = 1
	      and head.id_type_doc in (71,72)
	      and head.id_head <> ~($try ($g.d_head@GetValue 'HEAD.ID_HEAD') $catch ('Any')(-1))~
              and head_auto.id_automobile = ~($try ($g.d_head@GetValue 'HEAD_AUTO.ID_AUTOMOBILE') $catch ('Any')(-1))~
	      and head.date_sd <= '~($try ($($@date ($g.d_head@GetValue 'HEAD.DATE_SD') )@toPLString) $catch ('Any')(global.d1))~'
	   ) "
} // end of ds
// автомобиль забронирован?
{datastore  alias=dial3
    query="select head.id_head
             from head,head_auto
            where head.id_head = head_auto.id_head
	      and head.accept = 1
	      and head.id_type_doc = 74
	      and head.id_head <> ~($try ($g.d_head@GetValue 'HEAD.ID_HEAD') $catch ('Any')(-1))~
              and head_auto.id_automobile = ~($try ($g.d_head@GetValue 'HEAD_AUTO.ID_AUTOMOBILE') $catch ('Any')(-1))~
	      and head.date_sd  <='~($try ($($@date ($g.d_head@GetValue 'HEAD_AUTO.DATE_END_SD') )@toPLString) $catch ('Any')(global.d1))~'
	      and head_auto.date_end_sd >='~($try ($($@date ($g.d_head@GetValue 'HEAD.DATE_SD') )@toPLString) $catch ('Any')(global.d1))~'  
	    "
} // end of ds 
// автомобиль сдан в аренду?
{datastore  alias=dial4
    query="select head.id_head
             from head,head_auto
            where head.id_head = head_auto.id_head
	      and head.accept = 1
	      and head.id_type_doc = 75
	      and head.id_head <> ~($try ($g.d_head@GetValue 'HEAD.ID_HEAD') $catch ('Any')(-1))~
              and head_auto.id_automobile = ~($try ($g.d_head@GetValue 'HEAD_AUTO.ID_AUTOMOBILE') $catch ('Any')(-1))~
	      and head.date_sd  <='~($try ($($@date ($g.d_head@GetValue 'HEAD_AUTO.DATE_END_SD') )@toPLString) $catch ('Any')(global.d1))~'
	      and head_auto.date_end_sd >='~($try ($($@date ($g.d_head@GetValue 'HEAD.DATE_SD') )@toPLString) $catch ('Any')(global.d1))~'  
	    "
} // end of ds
// автомобиль выставлен на продажу?
{datastore  alias=dial5
    query="select head.id_head
             from head,head_auto
            where head.id_head = head_auto.id_head
	      and head.accept = 1
	      and head.id_type_doc = 79
	      and head.id_head <> ~($try ($g.d_head@GetValue 'HEAD.ID_HEAD') $catch ('Any')(-1))~
              and head_auto.id_automobile = ~($try ($g.d_head@GetValue 'HEAD_AUTO.ID_AUTOMOBILE') $catch ('Any')(-1))~
	      and head.date_sd <= '~($try ($($@date ($g.d_head@GetValue 'HEAD_AUTO.DATE_END_SD') )@toPLString) $catch ('Any')(global.d1))~'
	    "
} // end of ds
// автомобиль в ремонте?
{datastore  alias=dial6
    query="select head.id_head
             from head,head_auto
            where head.id_head = head_auto.id_head
	      and head.accept = 1
	      and head.id_type_doc = 76
	      and head.id_head <> ~($try ($g.d_head@GetValue 'HEAD.ID_HEAD') $catch ('Any')(-1))~
              and head_auto.id_automobile = ~($try ($g.d_head@GetValue 'HEAD_AUTO.ID_AUTOMOBILE') $catch ('Any')(-1))~
	      and head.date_sd  <='~($try ($($@date ($g.d_head@GetValue 'HEAD_AUTO.DATE_END_SD') )@toPLString) $catch ('Any')(global.d1))~'
	      and head_auto.date_end_sd >='~($try ($($@date ($g.d_head@GetValue 'HEAD.DATE_SD') )@toPLString) $catch ('Any')(global.d1))~'  
	    "
} // end of ds
{toolbar   BACKGROUND = "LIGHTGRAY"
{scrollpane 
{form width=780 height=208       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"
   }
  {label
       value="Дата окон."    
       left=300    top=8    height=20       width=50
       font_size=12         font_family=0   bg_color="#c0c0c0"
   }
   {field
       target=head_auto.date_end_sd  	    border = box
       left=355    top=8    height=20       width=70
       alias=date_end_sd        font_size=12    font_family=0    bg_color="#ffffff"
   }
 {field 
   type = string
   left = 300  top = 8  width = 100     height = 20 
   alias=ficd1           visible=no
   exp="($X 
          (global.d1 = ('\''+($($@date g.date_sd)@toPLString)+'\''))
          (ficd1 = global.d1)
	($ret '') )"
  }
   {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=11     top=33   height=20        width=65
       font_size=12         font_family=0    bg_color="#c0c0c0"
   }
   {field
       target=head.id_client1                 halignment = right
       left=80     top=33   height=20        width=70
       alias=cli1_numb_client                border = box        
       font_size=12         font_family=0    bg_color="#ffffff"
       editable=handbook
       edit="opennew util/sprav/find_client_e.rml"
       editexp="cli1_numb_client=STORE.client.id_client"
       dep="name_client1"
   }
   {field
      target=client.name1_client              border = box
      left=155     top=33   height=20        width=270
      alias=name_client1    font_size=12     font_family=0    bg_color="#ffffff"
      editexp="name_client1=STORE.client.name1_client"
      editable = readonly
   }
   {label
       value="Арендатор"
       left=11    top=58     height=20       width=65
       font_size=12          font_family=0   bg_color="#c0c0c0"
   }
   {field
       target=head.id_client2            halignment = right
       left=80    top=58     height=20       width=70         border = box
       alias=cli3_numb_client                font_size=12     font_family=0    bg_color="#ffffff"
       editable=handbook
       edit="opennew util/sprav/find_client_e.rml"
       editexp="cli3_numb_client=STORE.client.id_client"
       dep="name_client2"
   }
   {field
      target=client2.name1_client
      left=155    top=58     height=20       width=270        border = box
      alias=name_client2     font_size=12    font_family=0    bg_color="#ffffff"
      editexp="(name_client2=STORE.client.name1_client)
	       (g.comment2_sd=g.name_client2)"
           editable = readonly
   }
   {label
       value="Автомобиль"        
       left=11    top=83    height=20       width=70
       font_size=12         font_family=0   bg_color="#c0c0c0"
   }
   {field
       target=head_auto.id_automobile
       visible=no           border = box
       left=100    top=83    height=20       width=200
       alias=id_auto        font_size=12    font_family=0    bg_color="#ffffff"
       editexp="(id_auto=STORE.automobile.id_automobile)"
   }
   {field
       target=automobile.id_models_of_vehicle
       visible=no           border = box
       left=100    top=83    height=20       width=200
       alias=id_mod        font_size=12    font_family=0    bg_color="#ffffff"
       editexp="(id_mod=STORE.models_of_vehicle.id_models_of_vehicle)"
   }
   {field
       target=models_of_vehicle.name_of_models                 border = box
       left=100    top=83   height=20       width=200
       alias=name_mod          font_size=12    font_family=0    bg_color="#ffffff"
       editable=handbook
       edit="opennew util/sprav/find_auto_models.rml "
       editexp="name_mod=STORE.models_of_vehicle.name_of_models"
       dep="id_mod,id_auto,number_body,vin"
   }
   {label
       value="Рег. Номер"        
       left=310    top=83    height=20       width=70
       font_size=12         font_family=0   bg_color="#c0c0c0"
   }
   {field
       target=automobile.number_body
       border = box
       left=380    top=83    height=20       width=100
       alias=number_body        font_size=12    font_family=0    bg_color="#ffffff"
       editexp="(number_body=STORE.automobile.number_body)"
       editable=readonly
   }
   {label
       value="VIN"
       left=490    top=83    height=20       width=30
       font_size=12         font_family=0   bg_color="#c0c0c0"
   }
   {field
       target=automobile.vin
       border = box
       left=520    top=83    height=20       width=150
       alias=vin        font_size=12    font_family=0    bg_color="#ffffff"
       editexp="(vin=STORE.automobile.vin)"
       editable=readonly
   }
   {label
       value="Тип аренды"        
       left=11    top=108    height=20       width=70
       font_size=12         font_family=0   bg_color="#c0c0c0"
   }
   {field
       target=head_auto.id_type
       visible=no           border = box
       left=91    top=108    height=20       width=100
       alias=id_typ        font_size=12    font_family=0    bg_color="#ffffff"
       editexp="(id_typ=STORE.type_rent.id_type_rent)"
   }
   {field
       target=type_rent.name_type_rent                 border = box
       left=91    top=108    height=20       width=100
       alias=name_typ          font_size=12    font_family=0    bg_color="#ffffff"
       editable=handbook
       edit="opennew util/sprav/type_rent.rml "
       editexp="name_typ=STORE.type_rent.name_type_rent"
       dep="id_typ"
   }
   {label
       value="Исполнитель"  
       left=470  top=8      height=20       width=70
       font_size=12         font_family=0   bg_color="#c0c0c0"
   }
   {field
       target=personal.fname                border = box
       left=550    top=8    height=20       width=70
       alias=name           font_size=12    font_family=0    bg_color="#ffffff"
       editable = readonly
   }     
   {label
       value="Примечание"    
       left=11    top=133     height=20      width=65
       font_size=12          font_family=0  bg_color="#c0c0c0"
   }
   {field
       target=head.comment_sd   border = box
       left=91    top=133    height=20      width=495
       alias=comment_sd         font_size=12   font_family=0    bg_color="#ffffff"
   }
   {label
       value="Примечание2"    
       left=11    top=158     height=20      width=75
       font_size=12          font_family=0  bg_color="#c0c0c0"
   }
   {field
       target=head_auto.comment2_sd   border = box
       left=91    top=158    height=20      width=495
       alias=comment2_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.id_department1,head.id_department2,
                        head.id_client1,head.id_client2,client.name1_client,client2.name1_client,
                        head.comment_sd,head_auto.comment2_sd,
			head.id_personal,personal.fname,
			head.parent_id_head,
			head_auto.id_head,head_auto.id_automobile,head_auto.date_end_sd,
			head_auto.id_type,type_rent.name_type_rent,
            automobile.number_body, automobile.vin,
			automobile.id_models_of_vehicle,models_of_vehicle.name_of_models
                   from head,client,client client2,personal,head_auto,automobile,models_of_vehicle,type_rent
                  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_client1 = client.id_client 
                   and head.id_client2 = client2.id_client 
	           and head.id_head=head_auto.id_head
		   and head_auto.id_type = type_rent.id_type_rent
        	   and head_auto.id_automobile=automobile.id_automobile
		   and automobile.id_models_of_vehicle=models_of_vehicle.id_models_of_vehicle
                   and head.id_type_doc = 75"
              editable = yes
                  head = yes
                unique = "('head_auto','head_auto.id_head') ('head','head.id_head')"
               default = "head.id_head=~ds.hpk~,head.id_type_doc=~75~,
			  head_auto.id_head=~ds.hpk~,head_auto.id_automobile=~-1~,
                          head.date_sd=~ds.date~,head_auto.date_end_sd=~ds.date~,
			  head_auto.id_type=~-1~,
                          head.id_personal=~ds.idp~,
                          head.accept=~0~,
                          head.num_sd=~'СдАв-'~,
			  head.id_department1=~0~,
			  head.id_department2=~0~,
                          head.id_client1=~222~,
                          client.name1_client=~'ООО "АвтоРента"'~, 
                          head.id_client2=~1~,
                          client2.name1_client=~'Организация'~,
			  head.comment_sd = ~' '~"
} // 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)
             ((tmp = 'Вы действительно хотите сохранить все изменения и выйти' + '')
              (m = ($g.self@sure tmp 0))
               ($if (m == 1)
                      (($if (global.create == 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)
			  )
			)
	($debug 'g.dial1' )
                       ($g.dial1@retrieve)
                       ($IF (($G.dial1@size) == 0)
	                ((tmp = 'Автомобиль не введен в автопарк на   . Документ сохранить?!' + '')
            	         (m = ($g.self@sure tmp 0))
	                 ($if (m == 1)
	                   ($g.self@actdok)
                          $else ($g.self@actcancel)
                         )
			)
			$else
			 (
			  ($g.dial2@retrieve)
	($debug 'g.dial2' )
      			  ($IF (($G.dial2@size) != 0)
	                   ((tmp = 'Автомобиль выведен из автопарк на   . Документ сохранить?!' + '')
            	            (m = ($g.self@sure tmp 0))
	                    ($if (m == 1)
	                      ($g.self@actdok)
                             $else ($g.self@actcancel)
                            )
			   )
			   $else
			    (
			     ($g.dial3@retrieve)
	($debug 'g.dial3' )
  			     ($IF (($G.dial3@size) != 0)
	                      ((tmp = 'В этот период автомобиль забронирован. Документ сохранить?!' + '')
            	               (m = ($g.self@sure tmp 0))
	                       ($if (m == 1)
	                         ($g.self@actdok)
                                $else ($g.self@actcancel)
                               )
			      )
			      $else
			     (
			      ($g.dial4@retrieve)
	($debug 'g.dial4' )
  			      ($IF (($G.dial4@size) != 0)
	                       ((tmp = 'В этот период автомобиль сдан в аренду. Документ сохранить?!' + '')
            	                (m = ($g.self@sure tmp 0))
	                        ($if (m == 1)
	                          ($g.self@actdok)
                                 $else ($g.self@actcancel)
                                )
			       )
			       $else
			       (
			        ($g.dial5@retrieve)
	($debug 'g.dial5' )
  			        ($IF (($G.dial5@size) != 0)
	                         ((tmp = 'Автомобиль выставлен на продажу. Документ сохранить?!' + '')
            	                  (m = ($g.self@sure tmp 0))
	                          ($if (m == 1)
	                            ($g.self@actdok)
                                   $else ($g.self@actcancel)
                                  )
			         )
			         $else
			         (
			          ($g.dial6@retrieve)
	($debug 'g.dial6' )
  			          ($IF (($G.dial6@size) != 0)
	                           ((tmp = 'В этом периоде автомобиль в Ремонте. Документ сохранить?!' + '')
            	                    (m = ($g.self@sure tmp 0))
	                            ($if (m == 1)
	                              ($g.self@actdok)
                                     $else ($g.self@actcancel)
                                    )
			           )
			           $else
			            ($g.self@actdok)
                                  )	
	                         )       )	
	         )       )	
	         )       )	
		 )       )	
                 )       ))  ))
             $else ($g.self@actcancel)
	     ) 
             ($ret ''))"
  shortcut = "F3"
}
{button
  left = 11  width = 50    height = 20
  BACKGROUND = "LIGHTGRAY"    foreground="#000000"
  label = "Запис F4"
  action = "($X
             ($if (($g.D_HEAD@getvalue 'HEAD.ACCEPT') != 1)
               (($if (global.create == 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)
		  )
		)
	($debug 'g.dial1' )
                       ($g.dial1@retrieve)
                       ($IF (($G.dial1@size) == 0)
	                ((tmp = 'Автомобиль не введен в автопарк на   . Документ сохранить?!' + '')
            	         (m = ($g.self@sure tmp 0))
	                 ($if (m == 1)
	                   ($g.self@actsave)
                          $else ($g.self@actcancel)
                         )
			)
			$else
			 (
			  ($g.dial2@retrieve)
	($debug 'g.dial2' )
      			  ($IF (($G.dial2@size) != 0)
	                   ((tmp = 'Автомобиль выведен из автопарк на   . Документ сохранить?!' + '')
            	            (m = ($g.self@sure tmp 0))
	                    ($if (m == 1)
	                      ($g.self@actsave)
                             $else ($g.self@actcancel)
                            )
			   )
			   $else
			    (
			     ($g.dial3@retrieve)
	($debug 'g.dial3' )
  			     ($IF (($G.dial3@size) != 0)
	                      ((tmp = 'В этот период автомобиль забронирован. Документ сохранить?!' + '')
            	               (m = ($g.self@sure tmp 0))
	                       ($if (m == 1)
	                         ($g.self@actsave)
                                $else ($g.self@actcancel)
                               )
			      )
			      $else
			     (
			      ($g.dial4@retrieve)
	($debug 'g.dial4' )
  			      ($IF (($G.dial4@size) != 0)
	                       ((tmp = 'В этот период автомобиль сдан в аренду. Документ сохранить?!' + '')
            	                (m = ($g.self@sure tmp 0))
	                        ($if (m == 1)
	                          ($g.self@actsave)
                                 $else ($g.self@actcancel)
                                )
			       )
			       $else
			       (
			        ($g.dial5@retrieve)
	($debug 'g.dial5' )
  			        ($IF (($G.dial5@size) != 0)
	                         ((tmp = 'Автомобиль выставлен на продажу. Документ сохранить?!' + '')
            	                  (m = ($g.self@sure tmp 0))
	                          ($if (m == 1)
	                            ($g.self@actsave)
                                   $else ($g.self@actcancel)
                                  )
			         )
			         $else
			         (
			          ($g.dial6@retrieve)
	($debug 'g.dial6' )
  			          ($IF (($G.dial6@size) != 0)
	                           ((tmp = 'В этом периоде автомобиль в Ремонте. Документ сохранить?!' + '')
            	                    (m = ($g.self@sure tmp 0))
	                            ($if (m == 1)
	                              ($g.self@actsave)
                                     $else ($g.self@actcancel)
                                    )
			           )
			           $else
			            ($g.self@actsave)
                                  )	
	                         )       )	
	         )       )	
	         )       )	
		 )       )	
                 )       ))  
             $else ($g.self@actcancel)
	     )
            ($ret ''))"
  shortcut = "F4"
}
{button
  left = 72  width = 50    height = 20
  BACKGROUND = "LIGHTGRAY"    foreground="#000000"
  label = "Отмена ESC"
  action = "($X
             ($if (($g.D_HEAD@getvalue 'HEAD.ACCEPT') != 1)
              ((tmp = 'Вы действительно хотите выйти без сохранения данных' + '')
               (m = ($g.self@sure tmp 0))
                 ($if (m == 0)()
                 $else ($g.self@actcancel)
                 )
              )
             $else ($g.self@actcancel)
	     )
             ($ret ''))"
  shortcut = "escape"
}
} // toolbar

