<?
global $db;

ob_start();
?>
  <?= \Html::input(
              array(
                'label'   => 'Nazwa',
                'name'    => 'name',
                'id'      => 'name',
                'value'   => $this -> project['name'],
                'class'   => 'require',
                'inline'  => true
              )
          );?>
    <?
    $clients[ 0 ] = '--- wybierz klienta ---';
    if ( is_array( $this -> clients ) )
      foreach ( $this -> clients as $client )
        $clients[ $client[ 'id' ] ] = $client[ 'firm' ];
    ?>
    <?=
    \Html::select( [
        'label'  => 'Klient',
        'name'   => 'client_id',
        'id'     => 'client_id',
        'value'  => $this -> task[ 'id' ] ? $this -> task[ 'client_id' ] : 0,
        'values' => $clients
    ] );
    ?>
  <div class="form_group">
    <label class="label">Uczestnicy:</label>
    <div class="input">
      <? if ( is_array( $this -> users ) ): foreach ( $this -> users as $user ):?>
        <div class="group">
          <div class="name" id="user-<?= $user['id'];?>">
            <label for="user-<?= $user['id'];?>">
              <input type="checkbox" class="g-checkbox" name="users" value="<?= $user['id'];?>" <? if ( in_array( $user['id'], $this -> project['users'] ) ):?>checked="checked"<? endif;?>>
              <?= $user['name'] . ' ' . $user['surname'];?>
            </label>
          </div>
        </div>
      <? endforeach; endif;?>
    </div>
  </div>
<?
$out = ob_get_clean();

$grid = new \gridEdit;
$grid -> id               = 'project-edit';
$grid -> gdb_opt          = $gdb;
$grid -> include_plugins  = true;
$grid -> title            = 'Edycja <strong>projektu</strong>';
$grid -> fields           = [
                              [
                                'db' => 'id',
                                'type' => 'hidden',
                                'value' => $this -> project['id']
                              ]
                            ];
$grid -> external_code    = $out;
$grid -> actions          = [
                              'save' => [ 'url' => '/projects/project_save/', 'back_url' => '/projects/main_view/' ],
                              'cancel' => [ 'url' => '/projects/main_view/' ]
                            ];
$grid -> persist_edit     = true;
$grid -> id_param         = 'id';
echo $grid -> draw();
?>