<?php

class Manual_Model_Tipo extends Agro_Db_Table_Abstract {
    protected $_schema = 'sistema';
    protected $_name = 'tipo_manual';
    protected $_primary = 'id';
    public $_order = 'ds_nome_tipo';

    public function save($data) {
        $Row = $this->getRow($data['id']);
        $Row->ds_nome_tipo = $data['ds_nome_tipo'];
        return $Row->save();
    }

    public function getCombo() {
        $Select = $this->select();
        $Select->where('fl_ativo=true');
        $Select->order('ds_nome_tipo ASC');

        $Rs = $this->fetchAll($Select);

        $options = array();
        $options[] = '';
        if ($Rs->count()) {
            foreach ($Rs as $row) {
                $options[$row['id']] = $row['ds_nome_tipo'];
            }
        }

        return $options;
    }
}
