<?

class Safra12_Form_FHGranizo extends Agro_Form {
	
	public $id;
	public $id_laudo_preliminar;
	public $id_processo;
	public $id_cobertura;
	public $id_intensidade;
	public $fl_evento_nao_constatado;
	public $fl_acompanhado_vento;
	public $ds_direcao_evento;
	public $fl_acompanhado_chuva;
	public $fl_danos_benfeitorias;
	public $fl_area_atingida;
	public $fl_area_mesma_intensidade;
	public $ds_area_mesma_intensidade;
	public $dt_colheita;
	public $ds_estadio_cultura;
	public $ds_aspectos_gerais_cultura;
	public $ds_diametro_medio_frutos_variedade;
	public $ds_diametro_medio_granizo;
	public $fl_danos_folhas;
	public $fl_danos_ramos;
	public $fl_danos_flores;
	public $fl_danos_frutos;
	public $fl_danos_vegetacao_adjacente;
	public $fl_indenizacao_fitossanitaria;
	public $ds_observacao;
	
	public $ds_status;
		
	public $save;
	public $send;
	public $back;
	
	public $intensidade_options;
	
	public function init() {
		$this->id = $this->createElement('hidden', 'id');
		$this->id->setDecorators($this->buttonDecorator);
		$this->addElement($this->id);
		
		$this->id_laudo_preliminar = $this->createElement('hidden', 'id_laudo_preliminar');
		$this->id_laudo_preliminar->setDecorators($this->buttonDecorator);
		$this->addElement($this->id_laudo_preliminar);
		
		$this->id_processo = $this->createElement('hidden', 'id_processo');
		$this->id_processo->setDecorators($this->buttonDecorator);
		$this->addElement($this->id_processo);
		
		$this->id_cobertura = $this->createElement('hidden', 'id_cobertura');
		$this->id_cobertura->setDecorators($this->buttonDecorator);
		$this->addElement($this->id_cobertura);
		
		$this->fl_evento_nao_constatado = $this->createElement('checkbox', 'fl_evento_nao_constatado');
		$this->fl_evento_nao_constatado->setDecorators(array('ViewHelper'));
		$this->addElement($this->fl_evento_nao_constatado);
		
		$Intensidade = new Sinistro_Model_Intensidades();
		$this->intensidade_options = $Intensidade->getCombo(true,'ds_descricao');
		$this->id_intensidade = $this->createElement('select', 'id_intensidade');
		$this->id_intensidade->setDecorators($this->elementDecorator);
		$this->id_intensidade->setRequired(true);
		$this->id_intensidade->addMultiOptions($this->intensidade_options);
		$this->id_intensidade->setLabel('Intensidade do evento');
		$this->addElement($this->id_intensidade);
		
		$this->fl_acompanhado_vento = $this->createElement('checkbox', 'fl_acompanhado_vento');
		$this->fl_acompanhado_vento->setDecorators(array('ViewHelper'));
		$this->addElement($this->fl_acompanhado_vento);
		
		$this->fl_acompanhado_chuva = $this->createElement('checkbox', 'fl_acompanhado_chuva');
		$this->fl_acompanhado_chuva->setDecorators(array('ViewHelper'));
		$this->addElement($this->fl_acompanhado_chuva);
		
		$this->fl_danos_benfeitorias = $this->createElement('checkbox', 'fl_danos_benfeitorias');
		$this->fl_danos_benfeitorias->setDecorators(array('ViewHelper'));
		$this->addElement($this->fl_danos_benfeitorias);
				
		$this->ds_direcao_evento = $this->createElement('text', 'ds_direcao_evento');
		$this->ds_direcao_evento->setDecorators($this->elementDecorator);
		$this->ds_direcao_evento->setRequired(false);
		$this->ds_direcao_evento->setAttrib('size', '50');
		$this->ds_direcao_evento->setAttrib('maxlength', '30');
		$this->ds_direcao_evento->setLabel('Direção do evento');
		$this->addElement($this->ds_direcao_evento);
		
		$this->ds_diametro_medio_granizo = $this->createElement('text', 'ds_diametro_medio_granizo');
		$this->ds_diametro_medio_granizo->setDecorators($this->elementDecorator);
		$this->ds_diametro_medio_granizo->setRequired(false);
		$this->ds_diametro_medio_granizo->setAttrib('size', '50');
		$this->ds_diametro_medio_granizo->setAttrib('maxlength', '30');
		$this->ds_diametro_medio_granizo->setLabel('Diâmetro médio do granizo');
		$this->addElement($this->ds_diametro_medio_granizo);
		
		$this->fl_area_atingida = $this->createElement('radio', 'fl_area_atingida');
		$this->fl_area_atingida->setDecorators($this->elementDecorator);
		$this->fl_area_atingida->setRequired(true);
		$this->fl_area_atingida->addMultiOptions(array('T'=>'Total','P'=>'Parcial'));
		$this->fl_area_atingida->setLabel('Área atingida');
		$this->addElement($this->fl_area_atingida);
		
		$this->area_atingida_ha = $this->createElement('text', 'area_atingida_ha');
		$this->area_atingida_ha->setDecorators($this->elementDecorator);
		$this->area_atingida_ha->setRequired(false);
		$this->area_atingida_ha->setAttrib('size', '10');
		$this->area_atingida_ha->setAttrib('readonly', 'readonly');
		$this->area_atingida_ha->setLabel('ha');
		$this->addElement($this->area_atingida_ha);
				
		$this->fl_area_mesma_intensidade = $this->createElement('checkbox', 'fl_area_mesma_intensidade');
		$this->fl_area_mesma_intensidade->setDecorators(array('ViewHelper'));
		$this->addElement($this->fl_area_mesma_intensidade);
		
		$this->ds_area_mesma_intensidade = $this->createElement('textarea', 'ds_area_mesma_intensidade');
		$this->ds_area_mesma_intensidade->setDecorators($this->elementDecorator);
		$this->ds_area_mesma_intensidade->setAttrib('cols','50');
		$this->ds_area_mesma_intensidade->setAttrib('rows','5');
		$this->ds_area_mesma_intensidade->setAttrib('maxlength', '255');		
		$this->ds_area_mesma_intensidade->setLabel('Detalhes');
		$this->addElement($this->ds_area_mesma_intensidade);
		
		$this->dt_colheita = $this->createElement('text', 'dt_colheita');
		$this->dt_colheita->setDecorators($this->elementDecorator);
		$this->dt_colheita->setAttrib('size','11');
		$this->dt_colheita->setAttrib('class','data');
		$this->dt_colheita->addValidator(new Zend_Validate_Date('DD/MM/YYYY'));
		$this->dt_colheita->setRequired(false);
		$this->dt_colheita->setLabel("Mesma data para todas as quadras");
		$this->addElement($this->dt_colheita);
		
		$this->ds_estadio_cultura = $this->createElement('textarea', 'ds_estadio_cultura');
		$this->ds_estadio_cultura->setDecorators($this->elementDecorator);
		$this->ds_estadio_cultura->setAttrib('cols','84');
		$this->ds_estadio_cultura->setAttrib('rows','2');
		$this->ds_estadio_cultura->setAttrib('maxlength', '255');
		$this->ds_estadio_cultura->setLabel('Estádio da cultura');
		$this->ds_estadio_cultura->setRequired(true);
		$this->addElement($this->ds_estadio_cultura);
		
		$this->ds_aspectos_gerais_cultura = $this->createElement('textarea', 'ds_aspectos_gerais_cultura');
		$this->ds_aspectos_gerais_cultura->setDecorators($this->elementDecorator);
		$this->ds_aspectos_gerais_cultura->setAttrib('cols','84');
		$this->ds_aspectos_gerais_cultura->setAttrib('rows','2');
		$this->ds_aspectos_gerais_cultura->setAttrib('maxlength', '255');
		$this->ds_aspectos_gerais_cultura->setLabel('Aspectos gerais da cultura');
		$this->ds_aspectos_gerais_cultura->setRequired(true);
		$this->addElement($this->ds_aspectos_gerais_cultura);
		
		$this->ds_data_colheita_variedade = $this->createElement('textarea', 'ds_data_colheita_variedade');
		$this->ds_data_colheita_variedade->setDecorators($this->elementDecorator);
		$this->ds_data_colheita_variedade->setAttrib('cols','84');
		$this->ds_data_colheita_variedade->setAttrib('rows','2');
		$this->ds_data_colheita_variedade->setAttrib('maxlength', '255');
		$this->ds_data_colheita_variedade->setLabel('Data colheita variedade');
		$this->ds_data_colheita_variedade->setRequired(true);
		$this->addElement($this->ds_data_colheita_variedade);
		
		$this->ds_diametro_medio_frutos_variedade = $this->createElement('textarea', 'ds_diametro_medio_frutos_variedade');
		$this->ds_diametro_medio_frutos_variedade->setDecorators($this->elementDecorator);
		$this->ds_diametro_medio_frutos_variedade->setAttrib('cols','84');
		$this->ds_diametro_medio_frutos_variedade->setAttrib('rows','2');
		$this->ds_diametro_medio_frutos_variedade->setAttrib('maxlength', '255');
		$this->ds_diametro_medio_frutos_variedade->setLabel('Diâmeto médio dos frutos de cada variedade na data do início');
		$this->ds_diametro_medio_frutos_variedade->setRequired(true);
		$this->addElement($this->ds_diametro_medio_frutos_variedade);
		
		$this->fl_danos_folhas = $this->createElement('checkbox', 'fl_danos_folhas');
		$this->fl_danos_folhas->setDecorators(array('ViewHelper'));
		$this->addElement($this->fl_danos_folhas);
		
		$this->fl_danos_ramos = $this->createElement('checkbox', 'fl_danos_ramos');
		$this->fl_danos_ramos->setDecorators(array('ViewHelper'));
		$this->addElement($this->fl_danos_ramos);
		
		$this->fl_danos_flores = $this->createElement('checkbox', 'fl_danos_flores');
		$this->fl_danos_flores->setDecorators(array('ViewHelper'));
		$this->addElement($this->fl_danos_flores);
		
		$this->fl_danos_frutos = $this->createElement('checkbox', 'fl_danos_frutos');
		$this->fl_danos_frutos->setDecorators(array('ViewHelper'));
		$this->addElement($this->fl_danos_frutos);
		
		$this->fl_danos_vegetacao_adjacente = $this->createElement('checkbox', 'fl_danos_vegetacao_adjacente');
		$this->fl_danos_vegetacao_adjacente->setDecorators(array('ViewHelper'));
		$this->addElement($this->fl_danos_vegetacao_adjacente);
		
		$this->fl_indenizacao_fitossanitaria = $this->createElement('radio', 'fl_indenizacao_fitossanitaria');
		$this->fl_indenizacao_fitossanitaria->setDecorators($this->elementDecorator);
		$this->fl_indenizacao_fitossanitaria->setLabel('Indenização pela cobetura fitossanitária Pós Granizo?');
		$this->fl_indenizacao_fitossanitaria->addMultiOptions(array(true=>'Sim',false=>'Não'));
		$this->fl_indenizacao_fitossanitaria->setRequired(true);
		$this->addElement($this->fl_indenizacao_fitossanitaria);

		$this->fl_area_indenizacao = $this->createElement('radio', 'fl_area_indenizacao');
		$this->fl_area_indenizacao->setDecorators($this->elementDecorator);
		$this->fl_area_indenizacao->addMultiOptions(array('T'=>'Todas','P'=>'Parcial'));
		$this->fl_area_indenizacao->setLabel('Quadras com direito a indenização');
		$this->addElement($this->fl_area_indenizacao);
		
		$this->area_indenizacao_ha = $this->createElement('text', 'area_indenizacao_ha');
		$this->area_indenizacao_ha->setDecorators($this->elementDecorator);
		$this->area_indenizacao_ha->setRequired(false);
		$this->area_indenizacao_ha->setAttrib('size', '10');
		$this->area_indenizacao_ha->setAttrib('readonly', 'readonly');
		$this->area_indenizacao_ha->setLabel('ha');
		$this->addElement($this->area_indenizacao_ha);
		
		$this->ds_observacao = $this->createElement('textarea', 'ds_observacao');
		$this->ds_observacao->setDecorators($this->elementDecorator);
		$this->ds_observacao->setAttrib('cols','84');
		$this->ds_observacao->setAttrib('rows','2');
		$this->ds_observacao->setAttrib('maxlength', '255');		
		$this->ds_observacao->setLabel('Observações');
		$this->ds_observacao->setRequired(false);
		$this->addElement($this->ds_observacao);
		
		$this->ds_status = $this->createElement('hidden', 'ds_status');
		$this->ds_status->setDecorators($this->buttonDecorator);
		$this->addElement($this->ds_status);
		
		$this->save = $this->createElement('button', 'salvar', array('type'=>'submit'));
		$this->save->setDecorators($this->buttonDecorator);
		$this->save->setLabel('Salvar');
		$this->addElement($this->save);
		
		$this->send = $this->createElement('button', 'enviar', array('type'=>'submit'));
		$this->send->setDecorators($this->buttonDecorator);
		$this->send->setLabel('Enviar');
		$this->addElement($this->send);
		
		$this->back = $this->createElement('button', 'cancelar');
		$this->back->setDecorators($this->buttonDecorator);
		$this->back->setLabel('Voltar');
		$this->addElement($this->back);
	}
	
	public function setBttBack($idProcesso){
		$this->back->setAttrib('onclick','location.href="/sinistro/processo/view/id/'.$idProcesso.'"');
	}
	
}