Cp1251
DOC
foreground = lightgray 
document_width = 750
document_height = 550
document_title = "ZetaSE.Autocomplect/Приход ТМЦ"
preloadscript="
(global.retr = 0)
(global.id_h = 0)
(global.show_all = 0)
($defun refresh<arg>
  ($X
     ($g.grid_group1@retrieve)
     (g.sum1 = ($try ($g.gridds01@sum 'head.sum1_sd') $catch ('Any')(0)))
     (g.sum2 = ($try ($g.gridds01@sum 'HEAD.SUM2_SD - HEAD') $catch ('Any')(0)))
     (g.sum3 = ($try ($g.gridds01@sum 'head.sum2_sd') $catch ('Any')(0)))
     (g.sum4 = ($try ($g.gridds01@sum 'head.sum3_sd') $catch ('Any')(0)))
     ($ret '')
   )
)
"
postloadscript="
     (g.sum1 = ($try ($g.gridds01@sum 'head.sum1_sd') $catch ('Any')(0)))
     (g.sum2 = ($try ($g.gridds01@sum 'HEAD.SUM2_SD - HEAD') $catch ('Any')(0)))
     (g.sum3 = ($try ($g.gridds01@sum 'head.sum2_sd') $catch ('Any')(0)))
     (g.sum4 = ($try ($g.gridds01@sum 'head.sum3_sd') $catch ('Any')(0)))
"

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

{toolbar   BACKGROUND = "White"
{splitpanel type=vertical     percent=20
{treeview2
   alias=tree1  
   listAction="~($X 
                   ($refresh)
                   ($ret '')
               )~"  
   nodeAction="~($X 
                   ($refresh)
                   ($ret '')
               )~"  
   nodefont="Courier,bold|italic,12"      pointfont="Courier,italic,12"  
   hilite=gray,white
   node=blue   point=blue
   rootname="Поступление ТМЦ и услуг"
   hiliting=on
   storepath = yes

   {menu
        {item label = "Показать все документы"
         action="~($X
                    (global.show_all = 1)
                    ($g.self@doAction 'retrieve tree1')
                    ($ret '')
                  )~"
        }
   }

        {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 in (55)
                           ~($if (global.show_all != 0)
                              ('')
                            $else
                              # показывать последние два года
                              (' and head.date_sd > trunc(add_months(sysdate, -12), \'year\')')
                           )~"
                 grouping = "y;m;d"
                  sorting = "1;1;1"
        } // end of gr
} // end of tree
{ splitpanel type = horizontal percent = 80
{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 = "createnew docs/act_prih.rml -1, -1 ; retrieve tree1;retrieve gridds01"
    edit = "opennew docs/act_prih.rml ~($($GRID_GROUP1@getDatastore)@getValue 'HEAD.ID_HEAD' )~, -1 ;retrieve tree1; retrieve gridds01"
    del = "~($X
               (tmp = 'Вы действительно хотите удалить документ №' + ($($G.GRID_GROUP1@getDatastore)@getValue 'HEAD.NUM_SD' ) + '')
               (m = ($g.self@sure tmp 0))
               ($if (m == 0)
                   ($ret '')
               )
               ($g.self@doAction 'execute exec util.del_doc(' + ($($G.GRID_GROUP1@getDatastore)@getValue 'HEAD.ID_HEAD') + '); retrieve tree1; retrieve gridds01')
            ($ret ''))~"

   {menu
        {menu label = "Сформировать"
        	{item label = "Приход ТМЦ" action="createnew docs/act_prih.rml -1, -1 ; retrieve tree1;retrieve gridds01"}
        	{item label = "Копия прихода" action="createnew docs/act_prih.rml -1, ~($($GRID_GROUP1@getDatastore)@getValue 'HEAD.ID_HEAD' )~; retrieve tree1;retrieve gridds01"}
        	{item label = "Перемещение" action="createnew docs/sklad.rml -1, ~($($GRID_GROUP1@getDatastore)@getValue 'HEAD.ID_HEAD' )~"}
        } 
        {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" }            
        {item label = "-"}
        {menu label = "Печатные формы"

          {item label = "Печатная форма" action="open pech_form/pech_form_postup.rml ~($($GRID_GROUP1@getDatastore)@getValue 'HEAD.ID_HEAD' )~"}
          {item label = "M-4" action="open pech_form/pech_form_postup_m4.rml ~($($GRID_GROUP1@getDatastore)@getValue 'HEAD.ID_HEAD' )~"}
        }
        {item label = "-"}
        {item label = "Обновить" action="retrieve gridds01"}
        {item label = "-"}
        {item label = "Удалить"
           action = "~($X
                       ($IF (($($G.GRID_GROUP1@getDatastore)@getValue 'HEAD.ACCEPT' ) == 1)
		             ((tmp = 'Запрещено удалять проведенный документ')
            		      (m = ($g.self@sure tmp 1))
		             )
			$else
		         ((tmp = 'Вы действительно хотите удалить документ №' + ($($G.GRID_GROUP1@getDatastore)@getValue 'HEAD.NUM_SD' ) + '')
	                  (m = ($g.self@sure tmp 0))
		          ($if (m == 0)
                	   ($ret '')
	                  )
	                  ($g.self@doAction 'execute exec util.del_doc(' + ($($G.GRID_GROUP1@getDatastore)@getValue 'HEAD.ID_HEAD') + '); retrieve tree1; retrieve grid_group1')
			 )
		       )
	              ($ret ''))~"
        }
        {item label = "-"}
        {item label = "Присвоить активам поставщика"
           action = "~($X
	                 (tmp = 'Вы действительно хотите изменить поставщика всех активов этого документа?')
                         ($if (($g.self@sure tmp 0) == 0) ($ret '')  )
	                 ($g.self@doAction 'execute exec util.change_post(' + ($($G.GRID_GROUP1@getDatastore)@getValue 'HEAD.ID_HEAD') + ')')
                         ($ret '')
                      )~"
        }
   }
   {column size=30             title="X"
        target=head.accept
        title_font_family=2
        title_font_color="#000000"
        halignment=center
        font_size = 12     
   }
   {column size=40             title="номер"      alias=id_hd
        target=head.id_head        title_font_family=2     title_font_color="#000000"
        halignment=right           font_size = 12          font_family=0
        visible = no            alias=idh
   }
   {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=70             title="Дата док."
        target=head.date_sd        title_font_family=2     title_font_color="#000000"
        halignment=center          font_size = 12          font_family=0
   }
//   {column size=150            title="Поставщик"
//        target=client.name1_client  title_font_family=2     title_font_color="#000000"
//        halignment=left            font_size = 12          font_family=0
//   }
   {column size=170             title="Склад"
        target=head.id_department1           visible=no
        title_font_family=2        title_font_color="#000000"
        halignment=left            font_size = 12          font_family=0
   }                  
   {column size=170             title="Склад"
        target=department.name1_dep
        title_font_family=2        title_font_color="#000000"
        halignment=left            font_size = 12          font_family=0
   }                  
   //{column size=80            title="Сумма"
   //     target = "UTIL.DOC_SUM(HEAD.ID_HEAD)"
   //     title_font_family=2        title_font_color="#000000"
   //     halignment=right           font_size = 12          font_family=0
   //     editmask = "# #0.00"
   //}
   {column size=90            title="Количество"
        target = head.sum3_sd
        title_font_family=2        title_font_color="#000000"
        halignment=right           font_size = 12          font_family=0
        editmask = "# #0.000"
   }
//   {column size=90            title="Сумма без НДС"
//        target = head.sum1_sd
//        title_font_family=2        title_font_color="#000000"
//        halignment=right           font_size = 12          font_family=0
//        editmask = "# #0.00"
//   }
//   {column size=90            title="Сумма НДС"
//        target = "head.sum2_sd - head"
//        title_font_family=2        title_font_color="#000000"
//        halignment=right           font_size = 12          font_family=0
//        editmask = "# #0.00"
//   } 
//   {column size=90            title="Сумма"
//        target = head.sum2_sd
//        title_font_family=2        title_font_color="#000000"
//        halignment=right           font_size = 12          font_family=0
//        editmask = "# #0.00"
//   }      
   {column size=200             title="Примечание"
        target=head.comment_sd
        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.id_client2,client2.name1_client,
                           head.id_department1,department.name1_dep,head.comment_sd,
                           head.sum1_sd,
                           head.sum2_sd,
                           head.sum2_sd - head.sum1_sd,
                           head.sum3_sd,
                           head.accept
                      from head,client,department,client client2
                     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_client2 = client2.id_client (+)
                and head.id_department1 = department.id_department (+)                 
                and head.id_type_doc in (55)
           order by head.date_sd,head.num_sd"
           editable = yes
             unique = "('head','head.id_head')"
   } // end of ds
} // end of grid
{ form
//  {label left = 10 top = 10 width = 170 height = 30 font_size = 14 halignment = right value = "Сумма без НДС:" }
//
  { field left = 180 top = 10 width = 150 height = 30 font_size = 16 alias = sum1
    type = number  editmask = "# #0.00"  editable = readonly  halignment = right
    visible = no
  }
//  {label left = 10 top = 40 width = 170 height = 30 font_size = 14 halignment = right value = "Сумма НДС:" }
//
  { field left = 180 top = 40 width = 150 height = 30 font_size = 16 alias = sum2
    type = number  editmask = "# #0.00"  editable = readonly  halignment = right
    visible = no
  }
//  {label left = 10 top = 70 width = 170 height = 30 font_size = 14 halignment = center value = "Сумма c НДС:" }
//
  { field left = 180 top = 70 width = 150 height = 30 font_size = 16 alias = sum3
    type = number  editmask = "# #0.00"  editable = readonly halignment = right
    visible = no
  }
  {label left = 350 top = 10 width = 100 height = 30 font_size = 14 halignment = right value = "Количество:" }

  { field left =450 top = 10 width = 150 height = 30 font_size = 16 alias = sum4
    type = number  editmask = "# #0.00"  editable = readonly  halignment = right
  }
}
} // horizontal splipanel
} // end of split1
{button
  left = 72  width = 50    height = 20
  BACKGROUND = "LIGHTGREEN"    foreground="#000000"
  label = "Выход ESC"
  action = "($g.self@actcancel)"
  shortcut = "escape"
}

} // toolbar
