<?php

/*

 * Developer : John D'Alto (jdalto@yahoo.com)

 * Date : 9/1/2012

 * All code (c)2012 JLS Consulting, all rights reserved

 */



namespace Dorcas\TabithaBundle\Form\Type;



use Symfony\Component\Form\AbstractType;

use Symfony\Component\Form\FormBuilder;

use Doctrine\ORM\EntityRepository;

use Symfony\Component\OptionsResolver\OptionsResolverInterface;



class ClientInformationType extends AbstractType

{

    public function buildForm(FormBuilder $builder, array $options)

    {

        $builder->add('ssn', 'text', array('label' => 'Social Security No./Tax ID:', 'error_bubbling' => 'true', 'max_length' => 11));

        $builder->add('first_name', 'text', array('label' => 'First Name*:', 'error_bubbling' => 'true'));

        $builder->add('middle_name', 'text', array('label' => 'Middle:', 'max_length' => 20));

        $builder->add('last_name', 'text', array('label' => 'Last*:', 'error_bubbling' => 'true'));

        $builder->add('email', 'email', array('label' => 'Email:', 'error_bubbling' => 'true'));

        $builder->add('gender', 'choice', array(

            'choices'   => array('f' => 'Female', 'm' => 'Male'),

            'expanded'  => true,

            'multiple'  => false,

            'label' => 'Gender*:', 'error_bubbling' => 'true'));

        $builder->add('birth_date', 'date', array('label' => 'Birth Date*:',

            'input'  => 'datetime',

            'widget' => 'single_text',

            'format' => 'MM/dd/yyyy', 'error_bubbling' => 'true', 'invalid_message' => 'Please entered a valid Birth Date'));

        $builder->add('home_phone', 'text', array('label' => 'Home Ph:', 'max_length' => 14, 'error_bubbling' => 'true'));

        $builder->add('cell_phone', 'text', array('label' => 'Cell Ph:', 'max_length' => 14, 'error_bubbling' => 'true'));

        $builder->add('work_phone', 'text', array('label' => 'Work Ph:', 'max_length' => 14, 'error_bubbling' => 'true'));

        $builder->add('license_no', 'text', array('label' => 'License No:'));

        $builder->add('license_state', 'text', array('label' => 'State:', 'max_length' => 2));

 /*       

        $builder->add('ethnicity_id', 'entity', array(

            'label' => 'Ethnicity:',

            'class' => 'DorcasTabithaBundle:ListElement',

            'property' => 'name',

            'query_builder' => function(EntityRepository $er)  {

           

            $qb = $er->createQueryBuilder('le')

                   ->select('le')

                   ->where('le.listelementgroup = :leg_group_id')

                   ->orderBy('le.name', 'ASC')

                   ->setParameter('leg_group_id', '1');



        return $qb

                    

         //           return $er->createQueryBuilder('u') 

          //                  ->where('u.group_id = 1')

          //                  ->orderBy('u.name', 'ASC')

; },

                            ));







$builder->add('ethnicity_id', 'entity', array(

    'class' => 'DorcasTabithaBundle:ListElement',

   'empty_value' => 'Choose an option',

    'multiple' => true,



));



 

$builder->add('ethnicity_id','entity', 

            array( 

                'class'=>'DorcasTabithaBundle:Ethnicity',  

                'query_builder'=> function($repository){  

                            return $repository->createQueryBuilder('t')->orderBy('t.id', 'ASC'); 

                    }, 

                'property'=>'name', ) 

            ); 

                    

 

      

$builder->add('ethnicity_id','entity', 

                array( 

                    'class'=>'DorcasTabithaBundle:Ethnicity',  

                    'query_builder'=> function(\Dorcas\TabithaBundle\Repository\EthnicityRepository $repository){  

                                    return $repository->createQueryBuilder('s')->orderBy('s.id', 'ASC');}, 

                    'property'=>'title',  

                    'multiple'=>true 

                    ) 

                ); 



                                    

                                    

    $builder->add('ethnicity_id', 'choice', array(

    'choices'   => array(

        'morning'   => 'Morning',

        'afternoon' => 'Afternoon',

        'evening'   => 'Evening',

    ),

    'multiple'  => true,

));



  */          

                    

        $builder->add('ethnicity');



        $builder->add('employer', 'text', array('label' => 'Employer:'));

        $builder->add('employment_type', 'choice', array(

            'choices'   => array('f' => 'FT', 'p' => 'PT'),

            'expanded'  => true,

            'multiple'  => false,

            'label' => ''));

        $builder->add('alias', 'text', array('label' => 'Alias/Maiden Name:'));

        $builder->add('church_affiliation', 'text', array('label' => 'Church Affiliation:'));

        // $builder->add('spouse_other_name', 'text', array('label' => 'Spouse/Other Name:'));

        // $builder->add('spouse_other_ssn', 'text', array('label' => 'Spouse/Other SSN/Tax ID:'));

        // $builder->add('spouse_other_birthdate', 'date', array('label' => 'Spouse/Other Birthdate:',

            // 'input'  => 'datetime',

            // 'widget' => 'single_text',

            // 'format' => 'MM/dd/yyyy',

            // 'error_bubbling' => 'true',

            // 'invalid_message' => 'Please entered a valid Spouse Other Birth Date'));

			

			

			

		$builder->add('other_adult_oneFirstName', 'text', array('label' => 'Other Adult #1 First Name:'));

		$builder->add('other_adult_oneLastName', 'text', array('label' => 'Other Adult #1 Last Name:'));

		$builder->add('other_adult_oneSsn', 'text', array('label' => 'Other Adult #1 SSN/TaxID:', 'error_bubbling' => 'true'));

		$builder->add('other_adult_twoFirstName', 'text', array('label' => 'Other Adult #2 First Name:'));

		$builder->add('other_adult_twoLastName', 'text', array('label' => 'Other Adult #2 Last Name:'));

		$builder->add('other_adult_twoSsn', 'text', array('label' => 'Other Adult #2 SSN/TaxID:', 'error_bubbling' => 'true'));

	

			

        $builder->add('current_address', 'text', array('label' => 'Current Address:'));

        $builder->add('city', 'text', array('label' => 'City*:', 'error_bubbling' => 'true'));

        $builder->add('state', 'text', array('label' => 'State*:', 'error_bubbling' => 'true'));

        $builder->add('zipcode', 'text', array('label' => 'Zipcode:'));

        $builder->add('prev_address1', 'text', array('label' => 'Previous Address:'));

        $builder->add('prev_address2', 'text', array('label' => 'Previous Address:'));

//        $builder->add('prev_address3', 'text', array('label' => 'Previous Address:'));

        $builder->add('children', 'textarea', array('label' => 'Children:', 'max_length' => '255'));

		

    }

    

    public function getName()

    {

        return 'clientinformationform';

    }

    

        public function getDefaultOptions(array $options)

    {

        return array('data_class' => 'Dorcas\TabithaBundle\Entity\Client',);

    }

    

    public function setDefaultOptions(OptionsResolverInterface $resolver)

    {

    $resolver->setDefaults(array(

        'data_class' => 'Dorcas\TabithaBundle\Entity\Client',

    ));

    }

}

