<?php

class Sinistro2_Model_TiposMotivosQuadraNaoVistoriada extends Agro_Db_Table_Abstract {
	protected $_schema = 'sinistro';
	protected $_name = 'tipos_motivos_quadra_nao_vistoriada';
	protected $_primary = 'id';
	public $_order = 'ds_descricao';

    CONST DISPENSA_VISTORIA = 1;
	CONST DISPENSA_ITEM = 2;
    CONST ADIAMENTO_ITEM = 3;
    CONST ENCERRAMENTO_ITEM = 4;
    CONST AUTOMATICO = 5;
	
	public function getData($where=false) 
	{
		$select = $this->select()->setIntegrityCheck(false);
		$select->from("{$this->_schema}.{$this->_name}");

		if ($this->_order) {
			$select->order($this->_order);
		}

		$this->getWhere($select, $where);
		return $select;
	}

	public function save(array $data) {
		try {
			$Row = $this->getRow($data['id']);
			$Row->ds_descricao = $data['ds_descricao'];
			$Row->ds_chave = $data['ds_chave'];
				
			return $Row->save();
				
		} catch (Exception $e) {
			$this->setMessage($e->getMessage());
			return false;
		}
	}
}