<?
global $db;

ob_start();
?>
  <?
  if ( $this -> language['id'] )
  {
    echo \Html::input(
              array(
                'type'    => 'hidden',
                'name'    => 'id',
                'value'   => $this -> language['id']
              )
          );
    echo \Html::input(
              array(
                'type'    => 'hidden',
                'name'    => 'o',
                'value'   => $this -> language['o']
              )
          );
    echo \Html::input(
              array(
                'label'   => 'Język',
                'type'    => 'text',
                'class'   => 'require',
                'name'    => 'name',
                'value'   => $this -> language['name']
              )
          );
  }
  else
  {
    echo \Html::input(
              array(
                'type'    => 'hidden',
                'name'    => 'o',
                'value'   => $this -> order + 1
              )
          );
    echo \Html::input(
              array(
                'label'   => 'Język',
                'type'    => 'text',
                'class'   => 'require',
                'name'    => 'name'
              )
          );
    echo \Html::input(
              array(
                'label'   => 'ID (2 znaki)',
                'class'   => 'require',
                'type'    => 'text',
                'name'    => 'id'
              )
          );
  }
  ?>
  <?= \Html::input_switch(
              array(
                'label'   => 'Aktywny',
                'name'    => 'status',
                'checked' => $this -> language['status'] == 1 ? true : false
              )
          );?>
  <?= \Html::input_switch(
              array(
                'label'   => 'Domyślny',
                'name'    => 'start',
                'checked' => $this -> language['start'] == 1 ? true : false
              )
          );?>
<?
$out = ob_get_clean();

$grid = new \gridEdit;
$grid -> id               = 'language-edit';
$grid -> gdb_opt          = $gdb;
$grid -> include_plugins  = true;
$grid -> title            = 'Edycja języka';
$grid -> external_code    = $out;
$grid -> actions          = [ 
                              'save' => [ 'url' => '/admin/languages/language_save/', 'back_url' => '/admin/languages/view_list/' ], 
                              'cancel' => [ 'url' => '/admin/languages/view_list/' ] 
                            ];
$grid -> persist_edit     = true;
$grid -> id_param         = 'id';
echo $grid -> draw();
?>
<script type="text/javascript">
  $( function() 
  {
    disable_menu();
    
    $( 'input[type="text"].date' ).datetimepicker({
      format: "YYYY-MM-DD",
      pickTime: false
    });
  });
</script>