Cp1251
DOC 
foreground = lightgray
document_width = 1000
document_height = 700
document_title = "ZetaSE.Autocomplect/ Материалы и участки"
preloadscript="
"

postloadscript="($X

                   ($defun grid_color<arg>
                     ($X
                        (row = ($g.gridds01@getCurRow))
                        (i = 0)
                        ($while (i < ($g.gridds01@size))
                          (
                            ($g.gridds01@fastSetCurRow i)
                            #($debug 'row ' + i + ' work_area.id_work_area: ' + ($g.gridds01@getValue 'work_area.id_work_area'))
                            ($if (($try ($g.gridds01@getValue 'work_area.id_work_area') $catch ('NullException')(0)) == 0)
                                  ($g.gridspc@setRowBgColor i 'RED')
                             $else
                                  ($g.gridspc@setRowBgColor i 'WHITE')
                            )
                            (i += 1)
                          )
                        )
                        ($g.gridds01@fastSetCurRow row)
                        ($g.gridspc@repaint)
                        ($ret '')
                      )
                   )

                   ($grid_color)

                   ($ret '')
                )"


{toolbar   BACKGROUND = "LIGHTGRAY"
{grid
editable = no
alias = GRIDSPC
buttonbar_font_family=0       buttonbar_font_size=12           
buttonbar_size = 30           titlebar_size = 18            rowsize=20
titlebar_height = 30

del = ""


{menu
   {item label = "Участок: Армирование"
     action="~($X
                  ($g.self@doAction 'execute exec insert into view_work_area_active(id_work_area, id_active) values(1, ' + ($g.gridds01@getValue 'active_material.id_active')  + ')')
                  ($g.self@doAction 'execute exec commit')
                  (g.column_name_work_area = 'Армирование')
                  (g.column_id_work_area = 1)
                  ($grid_color)
                  ($ret '')
              )~"
   }
   {item label = "Участок: Нарезка"
     action="~($X
                  ($g.self@doAction 'execute exec insert into view_work_area_active(id_work_area, id_active) values(2, ' + ($g.gridds01@getValue 'active_material.id_active')  + ')')
                  ($g.self@doAction 'execute exec commit')
                  (g.column_name_work_area = 'Нарезка')
                  (g.column_id_work_area = 2)
                  ($grid_color)
                  ($ret '')
              )~"
   }
}

 {column size=50     
    title="Код"              font_family=0            editable = readonly 
    target=active_material.id_active     title_font_family=0      halignment=center
    font_color="#000000"     font_size=12
    editmask = "##0."
 }
 {column size=400
    title="Название"              font_family=0            editable = readonly 
    target=active_material.name_active     title_font_family=0      halignment=left
    font_color="#000000"     font_size=12
 }
 {column size=200     
    title="ID участка"              font_family=0                 editable = readonly 
    target=work_area.id_work_area     title_font_family=0      halignment=center
    font_color="#000000"     font_size=12
    alias = column_id_work_area       visible = no
 }
 {column size=200     
    title="Участок"              font_family=0                 editable = readonly 
    target=work_area.name_work_area     title_font_family=0      halignment=center
    font_color="#000000"     font_size=12
    alias = column_name_work_area
 }

  {datastore 
        alias = gridds01
        query = "select active_material.id_active, active_material.name_active, work_area.id_work_area, work_area.name_work_area
                   from spc, active, view_work_area_active, work_area, spc spc_spec, active active_material
                  where spc.id_head = ~ARGUMENTS.0~
                    and spc.id_active = active.id_active
                    and spc.parent_id_spc = 0
                    and active.id_head2 = spc_spec.id_head
                    and spc_spec.id_active = active_material.id_active
                    and active_material.id_active = view_work_area_active.id_active (+)
                    and view_work_area_active.id_work_area = work_area.id_work_area (+)
                  group by active_material.id_active, active_material.name_active, work_area.id_work_area, work_area.name_work_area
                  order by active_material.name_active"
  } // ds
} // grid
{button
  left = 72  width = 50    height = 20
  BACKGROUND = "LIGHTGRAY"    foreground="#000000"
  label = "Выход (ESC)"
  action = "$g.self@actcancel"
  shortcut = "escape"
}
} // toolbar

