<?php defined('BASEPATH') or exit('No direct script access allowed'); ?>
<?php init_head(); ?>
<div id="wrapper">
  <div class="content">
    <div class="row mbot15">
      <div class="col-md-12">
        <h4 class="tw-font-bold tw-text-xl"><?= _l('acabamentos'); ?></h4>
      </div>
    </div>
    <div class="_buttons mbot15">
      <a href="<?php echo admin_url('acabamentos/acabamento'); ?>" class="btn btn-primary">
        <i class="fa fa-plus"></i> <?= _l('new_acabamento'); ?>
      </a>
    </div>
    
    
    <div class="panel_s">
        <?php echo form_open(admin_url('acabamentos/acabamento' . (isset($acabamento) ? '/' . $acabamento->id : ''))); ?>
          <?php echo form_hidden('acabamentoid', isset($acabamento) ? $acabamento->id : ''); ?>
      <div class="panel-body">
          <div class="row">
            <div class="col-md-6">
              <?php 
                // render_select(name, options, [value_field,label_field], label, selected)
                echo render_select('item_group_id', $item_groups, ['id','name'], 'item_group', isset($acabamento) ? $acabamento->item_group_id : '');
              ?>
            </div>
            <div class="col-md-6">
              <?php 
                $value = isset($acabamento) ? $acabamento->name : '';
                echo render_input('name', 'acabamento_name', $value);
              ?>
            </div>
          </div>
      </div>
          <div class="panel-footer text-right">
            <button type="submit" class="btn btn-primary only-save">
              <?= _l('submit'); ?>
            </button>
          </div>
        <?php echo form_close(); ?>
    </div>
    
    
    <div class="panel_s">
      <div class="panel-body">
        <?php render_datatable([
            _l('item_group'),
            _l('acabamento_name'),
            _l('options'),
        ], 'acabamentos'); ?>
      </div>
    </div>
  </div>
</div>
<?php init_tail(); ?>
<script>
  $(function() {
    // Coluna 0 = Nome, Coluna 1 = Opções
    initDataTable('.table-acabamentos', window.location.href, [2], [2]);
  });
</script>
</body>
</html>