<?php

class Atendimento_Model_Proposta_Coberturas extends Agro_Db_Table_Abstract {
	protected $_schema = 'seguro';
	protected $_name = 'propostas_coberturas';
	protected $_primary = array('id_cobertura', 'id_proposta');
	
	public function save($values) {
		$Row = $this->find($values['id_cobertura'], $values['id_proposta'])->current();
		if (!$Row) $Row = $this->createRow();
		
		$Row->id_cobertura = $values['id_cobertura'];
		$Row->id_proposta = $values['id_proposta'];
		$Row->fl_principal = $values['fl_principal'];
		$Row->vl_franquia = $values['vl_franquia'];
		$Row->vl_taxa = $values['vl_taxa'];
		$Row->vl_premio = $values['vl_premio'];
		//$Row->vl_lmi = $values['vl_lmi'];
		
		return $Row->save();
	}
	
	public function clear($idCobertura, $idProposta) {
		$Row = $this->fetchRow("id_proposta = $idProposta and id_cobertura = $idCobertura");
			
		if ($Row) {
			$Row->delete();
		}
	}

}