Cp1251
DOC
foreground = lightgray 
document_width = 750
document_height = 550
document_title = "Заявки на аренду ТС"
style = "style/group.st"
preloadscript="
(global.retr = 0)
(global.id_h = 0)
"

{DSCollection
   alias = dscoll
   SeqQuery = "select to_char(sysdate) from dual"
   seqnames = "date"
}

{toolbar   BACKGROUND = "LIGHTGRAY"
{splitpanel type=vertical     percent=20
{treeview2
   alias=tree1  
   listAction="retrieve gridds01"  
   nodeAction="retrieve gridds01"  
   nodefont="Courier,bold|italic,12"      pointfont="Courier,italic,12"  
   hilite=gray,white
   node=blue   point=blue
   rootname="Заявки на аренду ТС"
   hiliting=on
   storepath = yes

        {groupreport 
          alias = datastore1
          query = "select distinct to_char(date_sd,'yyyy') y, to_char(date_sd,'mm') m ,
                          to_char(date_sd,'dd') d, date_sd 
                     from head
                    where head.id_type_doc = 97"
                 grouping = "y;m;d"
                  sorting = "1;1;1"
        } // end of gr
} // end of tree
{splitpanel     percent=80    gapsize=5
{grid
    alias = GRID_GROUP1
    buttonbar_font_family = 0              buttonbar_font_size = 12
    buttonbar_size = 30                    titlebar_size = 18
    multiselect = yes                      editable = no
    rowsize = 20
    add = "create docs/rent_ts.rml -1 ; retrieve tree1;retrieve gridds01"
    edit = "open docs/rent_ts.rml ~($($GRID_GROUP1@getDatastore)@getValue 'HEAD.ID_HEAD' )~ ;retrieve gridds01"
    del = "~($X
               (tmp = 'Вы действительно хотите удалить документ №' + ($($G.GRID_GROUP1@getDatastore)@getValue 'HEAD.NUM_SD' ) + '')
               (m = ($g.self@sure tmp 0))
               ($if (m == 0)
                   ($ret 'NOTDELETE')
               )
               ($g.self@doAction 'execute exec util.del_doc(' + ($($G.GRID_GROUP1@getDatastore)@getValue 'HEAD.ID_HEAD') + '); retrieve grid_group1')
            ($ret 'NOTDELETE'))~ ;retrieve gridds01"
   {menu
        {item label = "Обновить" action="retrieve gridds01"}
        {item label = "Обновить все" action="retrieve tree1;retrieve gridds01"}
        {item label = "Добавить" action="create docs/rent_ts.rml -1 ; retrieve tree1;retrieve gridds01"}
        {item label = "-"}
        {item label = "Просмотреть" action="open docs/rent_ts.rml ~($($GRID_GROUP1@getDatastore)@getValue 'HEAD.ID_HEAD' )~ ;retrieve gridds01"}
        {item label = "-"}
        {item label = "Удалить"
           action = "~($X
               (tmp = 'Вы действительно хотите удалить документ №' + ($($G.GRID_GROUP1@getDatastore)@getValue 'HEAD.NUM_SD' ) + '')
               (m = ($g.self@sure tmp 0))
               ($if (m == 0)
                   ($ret 'NOTDELETE')
               )
               ($g.self@doAction 'execute exec util.del_doc(' + ($($G.GRID_GROUP1@getDatastore)@getValue 'HEAD.ID_HEAD') + '); retrieve grid_group1')
            ($ret 'NOTDELETE'))~ ;retrieve gridds01"
        }
        {item label = "-"}
        {item label = "Выполнить" action= "execute exec ~'doc_lib.accept('+($($GRID_GROUP1@getDatastore)@getValue 'HEAD.ID_HEAD' )+')'~ ;retrieve gridds01" }
        {item label = "Отменить" action= "execute exec ~'doc_lib.de_accept('+($($GRID_GROUP1@getDatastore)@getValue 'HEAD.ID_HEAD' )+')'~ ;retrieve gridds01" }
   }
   {column size=70             title="Дата док."
        target=head.date_sd        title_font_family=2     title_font_color="#000000"
        halignment=center          font_size = 12          font_family=0
   }
   {column size=60             title="N док."
        target=head.num_sd         title_font_family=2     title_font_color="#000000"
        halignment=left            font_color="#000000"     
        font_size = 12             font_family=0
   }
   {column size=50             title="Статус"
        target=head.accept
        title_font_family=2
        title_font_color="#000000"
        halignment=center
        font_size = 12     
   }
   {column size=80             title="Дата начала"
        target=head.date_per_sd        title_font_family=2     title_font_color="#000000"
        halignment=center          font_size = 12          font_family=0
   }
   {column size=80             title="Дата оконч."
        target=head_auto.date_end_sd        title_font_family=2     title_font_color="#000000"
        halignment=center          font_size = 12          font_family=0
   }
   {column size=200            title="Контрагент"
        target=client.name1_client  title_font_family=2     title_font_color="#000000"
        halignment=left            font_size = 12          font_family=0
   }
   {column size=150            title="Контактное лицо"
        target=head_auto.comment2_sd  title_font_family=2     title_font_color="#000000"
        halignment=left            font_size = 12          font_family=0
   }   
   {column size=150             title="Примечание"
        target=head.comment_sd
        title_font_family=2        title_font_color="#000000"
        halignment=left            font_size = 12          font_family=0
   }
   {column size=70             title="Подразделение"
        target=department.name1_dep
        title_font_family=2        title_font_color="#000000"
        halignment=left            font_size = 12          font_family=0
   } 
   {datastore 
           alias = GRIDDS01
           query = "select head.id_head,head.num_sd,head.date_sd,
			               head.id_client1,client.name1_client,head.date_per_sd,
                           head_auto.id_head,head_auto.date_end_sd,head_auto.comment2_sd,
                           head.id_department1,department.name1_dep,head.comment_sd,
                           head.accept
                      from head,client,department,head_auto
                     where head.date_sd ~ 
         ($if (($g.tree1@getLevel) == 0)
                   ($try ('=to_date(\''+
                   #  '01-01-0001' +
                   dscoll.date+                 
                  '\',\'dd-mm-yyyy\')') 
                $catch ('Any') ('=\'11-11-1999\'')
                    )
                $if (($g.tree1@getLevel) == 1)
                    ($try ('between
                            to_date(\'01-01-'+
                            datastore1.y+
             '\',\'dd-mm-yyyy\')
                         and
                            to_date(\'31-12-'+
                            datastore1.y+
             '\',\'dd-mm-yyyy\')')
                     $catch ('Any') ('=\'01-01-1999\'')
                     )               
                 $if (($g.tree1@getLevel) == 2)
                     ($if (($@number (datastore1.m)) == 12)
                          ($try ('between
                                  to_date(\'01-12-'+
                                  datastore1.y+
                   '\',\'dd-mm-yyyy\')
                                  and
                                  to_date(\'31-12-'+
                                  datastore1.y+
                   '\',\'dd-mm-yyyy\')')
                            $catch ('Any') ('=\'01-01-1999\'')
                            )                                  
                      $else ($try (' >= to_date(\'01-'+
                                      datastore1.m+                
                       '-'+
                       datastore1.y+
                       '\',\'dd-mm-yyyy\') 
                                  and 
                              date_sd < to_date(\'01-'+
                       ($(($@number (datastore1.m))+1)@int)+
                                      '-'+
                                      datastore1.y+
                       '\',\'dd-mm-yyyy\')')
                      $catch ('Any') ('=\'11-11-1999\'')
                      )  
                     )              
                 $else ($try ('=to_date(\''+
                  datastore1.d+
                  '-'+
                  datastore1.m+
                  '-'+
                  datastore1.y+
                  '\',\'dd-mm-yyyy\')') 
                    $catch ('Any') ('=\'11-11-1999\'')
                        )
                 ) ~ 
                and head.id_client1 = client.id_client (+)
                and head.id_department1 = department.id_department (+)
                and head.id_head = head_auto.id_head                 
                and head.id_type_doc = 97
           order by head.date_sd,head.num_sd"
           editable = yes
             unique = "('head_auto','head_auto.id_head') ('head','head.id_head')"
   } // end of ds
} // end of grid
{grid   alias=grid_docs
}
} // end of split2
} // end of split1
{button
  left = 72  width = 50    height = 20
  BACKGROUND = "LIGHTGRAY"    foreground="#000000"
  label = "Выход ESC"
  action = "($g.self@actcancel)"
  shortcut = "escape"
}

} // toolbar
