<?php

class Atendimento_Form_Contato extends Agro_Form {
	
	public function init() {
		$Estado = new Sistema_Model_Estados();
		
		$this->addElement('hidden', 'id', array('decorators' => $this->buttonDecorator));
		
		$this->addElement('text', 'ds_nome_contato', array(
			'decorators' => $this->elementDecorator,
			'required' => true,
			'maxlength' => 100,
			'label' => 'Nome',
			'size' => 40
		));
		
		$this->addElement('text', 'ds_nome_fantasia', array(
			'decorators' => $this->elementDecorator,
			'label' => 'Nome Fantasia',
			'required' => true,
			'maxlength' => 100,
			'size' => 40
		));
		
		$this->addElement('text', 'ds_razao_social', array(
			'decorators' => $this->elementDecorator,
			'label' => 'Razão Social',
			'required' => true,
			'maxlength' => 100,
			'size' => 40
		));
		
		$this->addElement('text', 'ds_cargo', array(
			'decorators' => $this->elementDecorator,
			'label' => 'Cargo',
			'required' => false,
			'maxlength' => 100,
			'size' => 40
		));
		
		$this->addElement('text', 'ds_assistente', array(
			'decorators' => $this->elementDecorator,
			'label' => 'Assistente',
			'required' => false,
			'maxlength' => 100,
			'size' => 40
		));
		
		$this->addElement('text', 'ds_profissao', array(
			'decorators' => $this->elementDecorator,
			'label' => 'Profissão',
			'required' => false,
			'maxlength' => 100,
			'size' => 40
		));
		
		$this->addElement('text', 'ds_apelido', array(
			'decorators' => $this->elementDecorator,
			'label' => 'Apelido',
			'required' => false,
			'maxlength' => 100,
			'size' => 40
		));
		
		$EstadoCivil = new Sistema_Model_EstadosCivis();
		$this->addElement('select', 'id_estado_civil', array(
			'decorators' => $this->elementDecorator,
			'MultiOptions' => $EstadoCivil->getCombo(true,'ds_nome_estado_civil'),
			'required' => false,
			'RegisterInArrayValidator' => false,
			'label' => 'Estado Civil'
		));
		
		$this->addElement('text', 'dt_nascimento', array(
			'decorators' => $this->elementDecorator,
			'label' => 'Data Nascimento',
			'maxlength' => 10,
			'required' => false,
			'class' => 'data',
			'size' => 11
		));
		
		$this->addElement('text', 'dt_ultima_visita', array(
			'decorators' => $this->elementDecorator,
			'label' => 'Data Última Visita',
			'required' => true,
			'maxlength' => 10,
			'class' => 'data',
			'size' => 11
		));
		
		$this->addElement('text', 'ds_conjuge', array(
			'decorators' => $this->elementDecorator,
			'label' => 'Conjuge',
			'maxlength' => 100,
			'required' => false,
			'size' => 40
		));
		
		$this->addElement('text', 'ds_numero_filhos', array(
			'decorators' => $this->elementDecorator,
			'label' => 'Número de Filhos',
			'maxlength' => 2,
			'required' => false,
			'class' => 'integer',
			'size' => 10
		));
		
		$this->addElement('text', 'ds_email_pessoal', array(
			//'validators' => array(array('validator'=> new Zend_Validate_EmailAddress())),
			'decorators' => $this->elementDecorator,
			'label' => 'E-mail Pessoal',
			'required' => false,
			'maxlength' => 100,
			'size' => 40
		));
		
		$this->addElement('text', 'ds_email_comercial', array(
			//'validators' => array(array('validator'=> new Zend_Validate_EmailAddress())),
			'decorators' => $this->elementDecorator,
			'label' => 'E-mail Comercial',
			'required' => false,
			'maxlength' => 100,
			'size' => 40
		));
		
		$this->addElement('text', 'ds_site_pessoal', array(
			'decorators' => $this->elementDecorator,
			'label' => 'Site Pessoal',
			'maxlength' => 100,
			'required' => false,
			'size' => 40
		));
		
		$this->addElement('text', 'ds_site_comercial', array(
			'decorators' => $this->elementDecorator,
			'label' => 'Site Comercial',
			'maxlength' => 100,
			'required' => false,
			'size' => 40
		));
		
		$Categorias = new Atendimento_Model_Contatocategoria();
		$this->addElement('select', 'id_contatos_categorias', array(
			'decorators' => $this->elementDecorator,
			'MultiOptions' => $Categorias->getCombo(true, 'ds_nome_categoria'),
			'required' => true,
			'RegisterInArrayValidator' => true,
			'label' => 'Categoria'
		));
	
		$Estado = new Sistema_Model_Estados();
		$this->id_estado_search = $this->createElement('select', 'id_estado_search');
		$this->id_estado_search->setDecorators($this->elementDecorator);
		$this->id_estado_search->addMultiOptions($Estado->getCombo());
		$this->id_estado_search->setLabel('Estado');
		$this->addElement($this->id_estado_search);
		
		$this->id_municipio_search = $this->createElement('select', 'id_municipio_search');
		$this->id_municipio_search->setDecorators($this->elementDecorator);
		$this->id_municipio_search->setLabel('Município');
		$this->addElement($this->id_municipio_search);	
	}
	
	public function populate(array $values) {
		$values['dt_ultima_visita'] = Agro_Util::formatDate($values['dt_ultima_visita'], Zend_Date::DATES);
		$values['dt_nascimento'] = Agro_Util::formatDate($values['dt_nascimento'], Zend_Date::DATES);
		
		parent::populate($values);
	}
}