<?php

class Sinistro2_Form_AcoesVistoria extends Agro_Form {
	
	protected $tipo_vistoria;
	protected $id_vistoria;
	protected $id_laudo;
	
	public function __construct(array $params = array(), $options = null){
		$this->tipo_vistoria = $params['tipo'];
		$this->id_vistoria = $params['id_vistoria'];
		$this->id_laudo = $params['id_laudo'];
		parent::__construct($options);
	}
	
	public function init() {
		$this->addElement('hidden', 'id', array('decorators' => $this->elementDecorator));
		$this->addElement('hidden', 'tipo_vistoria', array('decorators' => $this->elementDecorator));
		$this->addElement('hidden', 'id_vistoria', array('decorators' => $this->elementDecorator));
		$this->addElement('hidden', 'id_laudo', array('decorators' => $this->elementDecorator));
		
		$this->addElement('checkbox', 'fl_vistoria_status', array('decorators' => $this->elementDecorator));

		$ModelStatus = new Sistema_Model_Status();
		$combo = $ModelStatus->getCombo($this->tipo_vistoria);

		if(Zend_Auth::getInstance()->getIdentity()->id_empresa != 20){
			foreach ($combo as $key => $value){
				if($value == "6 - Cancelado por culpa do Segurado"){
					$comboStatus[$key] = $value;
				}
			}
		}else{
			$comboStatus = $combo;
		}

		$this->addElement('select', 'vistoria_status', array(
				'decorators' => $this->elementDecorator,
				'required' => true,
				'MultiOptions' => $comboStatus,
				'disabled'	=> true
		));

		$this->addElement('textarea', 'obs_vistoria_status', array(
				'decorators' => $this->elementDecorator,
				'required' => true,
				'cols' => '30',
				'rows'	=> '3',
				'disabled'	=> true
		));

		$this->addElement('checkbox', 'fl_vistoria_valida', array(
				'decorators' => $this->elementDecorator,
				
		));

		$this->addElement('select', 'vistoria_valida', array(
				'decorators' => $this->elementDecorator,
				'MultiOptions' => array(1 => 'Válida', 0 => 'Inválida'),
				'disabled'	=> true

		));

		$this->addElement('textarea', 'obs_vistoria_valida', array(
				'decorators' => $this->elementDecorator,
				'required' => true,
				'cols' => '30',
				'rows'	=> '3',
				'disabled'	=> true
		));

		$this->addElement('checkbox', 'fl_vistoria_tablet', array(
				'decorators' => $this->elementDecorator
		));

		$this->addElement('select', 'vistoria_tablet', array(
				'decorators' => $this->elementDecorator,
				'MultiOptions' => array(0 => 'Via Agronet', 1 => 'Via Tablet'),
				'disabled'	=> true
		));

		$this->addElement('textarea', 'obs_vistoria_tablet', array(
				'decorators' => $this->elementDecorator,
				'cols' => '30',
				'rows'	=> '3',
				'disabled'	=> true
		));

		$this->addElement('checkbox', 'fl_vistoria_tablet_identificador', array(
				'decorators' => $this->elementDecorator
		));

		$this->addElement('text', 'vistoria_tablet_identificador', array(
				'decorators' => $this->elementDecorator,
				'disabled'	=> true
		));

		$this->addElement('textarea', 'obs_vistoria_tablet_identificador', array(
				'decorators' => $this->elementDecorator,
				'required' => true,
				'cols' => '30',
				'rows'	=> '3',
				'align' => 'right',
				'disabled'	=> true
		));		
	}
	
	public function populate($values){

		$this->getElement('vistoria_status')->setValue($values['vistoria_status']);
		$this->getElement('vistoria_valida')->setValue($values['vistoria_valida']);
		$this->getElement('vistoria_tablet')->setValue($values['vistoria_tablet']);
		$this->getElement('vistoria_tablet_identificador')->setValue($values['vistoria_tablet_identificador']);
		
		$this->getElement('id_vistoria')->setValue($values['id_vistoria']);
		$this->getElement('id_laudo')->setValue($values['id_laudo']);
		$this->getElement('tipo_vistoria')->setValue($values['tipo']);
	}

}