summaryrefslogblamecommitdiffstats
path: root/application/forms/EventAdd.php
blob: af34f848e172e81225853dd01b8c77a3d1a569f1 (plain) (tree)
1
2
3
4
5
6
7
8
9


                                                 
 
                                


                                   
                       
                     
                                        
 



                                                           
 


                                             













                                                   
 


















                                                                





                                        




                                  




                                    
 
                                                   
         
                                                     

         
                                                                          
         
                                                                        
         
 
                              
         


                                           




                                                                                


                                                                                 




                                                                                                     


                                                                                     

                                                       


                                                         
                                                           
                  


                                               
 

                                                                 
                                                      

                                            
 


                                                         
                                                           
                                                                          
                  
                                           
                                                                  
                                                   
                   
 


                                                         
                                                           
                                                                          
                                                                                                                                                  
                  
                                            
                                                                
                                                 
                   
                                                                                                                
 
                                                              
                                                                



                                             
 







                                                                       
 


                                                                
                                                           
                  

                                                   

                   


                                                         

                                                            


                                            
 




                                                                         
                                                                                        





                                                               




                                                                             
                                                                                          





                                                                 



                                                         


                                                                    



                                                                                    

                           
                                                             
                                                        






                                                                         
         
 
<?php

class Application_Form_EventAdd extends Zend_Form
{
	private $membershiplist;
	private $bootoslist;
	private $poollist;
	private $eventcategorylist;
	private $start;
	private $end;
	private $defaultEventCategoryID;

	public function setMembershiplist($membershiplist){
		$this->membershiplist = $membershiplist;
			
	}

	public function getMembershiplist(){
		return $this->membershiplist;
	}

	public function setBootoslist($bootoslist){
		$this->bootoslist = $bootoslist;
			
	}

	public function getBootoslist(){
		return $this->bootoslist;
	}

	public function setPoollist($poollist){
		$this->poollist = $poollist;
			
	}

	public function getPoollist(){
		return $this->poollist;
	}

	public function getEventcategorylist()
	{
		return $this->eventcategorylist;
	}

	public function setEventcategorylist($eventcategorylist)
	{
		$this->eventcategorylist = $eventcategorylist;
	}

	public function getStart()
	{
		return $this->start;
	}

	public function setStart($start)
	{
		$this->start = $start;
		return $this;
	}

	public function getEnd()
	{
		return $this->end;
	}

	public function setEnd($end)
	{
		$this->end = $end;
		return $this;
	}

	public function getDefaultEventCategoryID()
	{
		return $this->defaultEventCategoryID;
	}

	public function setDefaultEventCategoryID($defaultEventCategoryID)
	{
		$this->defaultEventCategoryID = $defaultEventCategoryID;
	}

	public function init()
	{
		$this->setName('EventAdd');
		$this->setMethod('post');

		$eventcategoryfield = $this->createElement('select','category');
		$eventcategoryfield ->setLabel('Category:');

		if(count($this->eventcategorylist)>0){
			foreach($this->eventcategorylist as $category => $c){
				$title = $c->getTitle();
				$id = $c->getID();
				$eventcategoryfield->addMultiOption($id, $title);
			}
		}

		$eventcategoryfield->setRegisterInArrayValidator(false);
		$eventcategoryfield->setAttrib('onchange', "eventcategoryfieldChanged('category');");
		if(isset($this->defaultEventCategoryID)) {
			$eventcategoryfield->setValue($this->defaultEventCategoryID);
		}
		$this->addElement($eventcategoryfield);

		$this->addElement('text', 'title', array(
			'filters' => array('StringTrim'),
			'validators' => array(
		array('StringLength', false, array(0, 30)),
		),
			'required' => true,
			'label'    => 'Title:',
		));

		$this->addElement('checkbox', 'immediate', array(
			'required' => false,
			'label' => 'Immediate Event:',
			'value'=>array(0,1),
		));

		$this->addElement('text', 'start', array(
			'filters' => array('StringTrim'),
			'validators' => array(
		array('StringLength', false, array(0, 16)),
		array('Date', false, array('format' => 'mm/dd/yyyy H:i')),
		),
			'required' => true,
			'label'    => 'Start (mm/dd/yyyy H:min):',
		 	'value'    => $this->start,
		));

		$this->addElement('text', 'end', array(
			'filters' => array('StringTrim'),
			'validators' => array(
		array('StringLength', false, array(0, 16)),
		array('Date', false, array('format' => 'mm/dd/yyyy H:i')),
		array('DateGreaterThan', false, array('element' => 'End', 'compare' => 'Start', 'min' => $this->getElement('start')->getValue())),
		),
			'required' => false,
			'label'    => 'End (mm/dd/yyyy H:min):',
		 	'value'    => $this->end,
		));
		$this->getElement('end')->addPrefixPath('Poolctrl_Validate', 'Poolctrl/Validator/', 'validate');

		$this->addElement('checkbox', 'repeat', array(
			'onchange' => 'repeatChanged("repeat")',
			'required' => false,
			'label' => 'Repeat:',
			'value'=>array(0,1),
		));

		$this->addElement('text', 'repeatEnd', array(
			'filters' => array('StringTrim'),
			'validators' => array(
		array('StringLength', false, array(0, 16)),
		),
			'required' => false,
			'label'    => 'Repeat end (mm/dd/yyyy H:min):',
		));

		$this->addElement('text', 'participants', array(
			'filters' => array('StringTrim'),
			'validators' => array(
		array('StringLength', false, array(0, 40)),
		),
			'required' => false,
			'label' => 'Participants:',
		));

		$this->addElement('text', 'note', array(
			'filters' => array('StringTrim'),
			'validators' => array(
		array('StringLength', false, array(0, 140)),
		),
			'required' => false,
			'label' => 'Note:',
		));

		$poolfield = $this->createElement('select','pbs_poolID');
		$poolfield ->setLabel('Pool:');

		if(count($this->poollist)>0){
			foreach($this->poollist as $pool => $p){
				$poolfield->addMultiOption($p->getID(), $p->getTitle());
			}
		}

		$poolfield->setRegisterInArrayValidator(false);
		$this->addElement($poolfield);

		$bootosfield = $this->createElement('select','pbs_bootosID');
		$bootosfield ->setLabel('BootOS:');

		if(count($this->bootoslist)>0){
			foreach($this->bootoslist as $bootos => $b){
				$bootosfield->addMultiOption($b->getID(), $b->getTitle());
			}
		}

		$bootosfield->setRegisterInArrayValidator(false);
		$this->addElement($bootosfield);

		$this->addElement('submit', 'add', array(
			'required' => false,
			'ignore'   => true,
			'label'    => 'Create Event'
			));

			$this->addElement('button', 'cancel', array(
			'required' => false,
			'ignore'   => true,
			'label'    => 'Cancel',
			'onclick'   => 'location.href="javascript:history.back();"',
			));

			echo '<script type="text/javascript">
				repeatChanged("repeat");
				eventcategoryfieldChanged("category");
				$(function() {
					$("#start").datetimepicker();
					$("#end").datetimepicker();
					$("#repeatEnd").datetimepicker();
				});
			</script>';
	}
}