.page-header
  %h2
    %li.icon-table
    = Yii::t("app", "Query")

%h4=t('Query').':'
%form(method="post")
  =t('View')
  %input(name="action" type="radio" value="return" checked="checked")
  =t('Export')
  %input(name="action" type="radio" value="export")
  %br
  =t('Editable')
  -if($editable)
    %input(name="editable" type="checkbox" value="1" checked="checked")
  -else
    %input(name="editable" type="checkbox" value="1")
  %br
  %br
  %textarea#querySql(name="query" cols="10" rows="30" style="width: 100%; height: 100px;font-family: monospace;")=$sql
  %input(type="submit")
  
-if(isset($messages) && count($messages)>0)
  %h4=t('Messages').':'
  %pre=implode(PHP_EOL,$messages)

-if(isset($results))
  %h4=t('Results').':'
  -if(count($results)<=0)
    %i=t('No results')
  -else
    -$rowIndex=0
    %table(border=1)
      -foreach($results as $row)
        -$data = $row->toArray()
        -if($rowIndex == 0)
          -$columns = array_keys($data)
          %thead
            %tr
              -foreach($columns as $col)
                %th=$col
        %tbody
          -if($rowIndex==1)
          %tr
            -foreach($columns as $col)
              %td
                -if($editable)
                  %input(type="text" value="#{$data[$col]}")
                -else
                  =$data[$col]
        -$rowIndex++

%h4=t('Current database').': '.$db
%h5
  =t('Tables').': '
  !=implode(', ',$tables)

%script
  !="$('#querySql').focus()"