1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202
| /**
* Build a form to select a project from those in DB
* @return form
*/
protected function getFormSelectProject()
{
//Get All projects
$em = $this->getDoctrine()->getManager();
$rep = $em->getRepository('ATSCapacityPlanBundle:Project');
$projects = $rep->findAll();
// Get form to display Config
$builder = $this->createFormBuilder();
$builder->add('projects', 'entity', array(
'label' => 'Select a project ',
'class' => 'ATSCapacityPlanBundle:Project',
'property' => 'name',
'choices' => $projects,
'attr' => array('class'=>'btn')));
$submitOptions = array('label' => 'Display', 'attr'=>array('class'=>'btn'));
$builder->add('display', 'submit', $submitOptions);
$submitOptions2 = array('label' => 'Create New Project', 'attr'=>array('class'=>'btn'));
$builder->add('create', 'submit', $submitOptions2);
$submitOptions3 = array('label' => 'Delete Selected Project', 'attr'=>array('class'=>'btn'));
$builder->add('delete', 'submit', $submitOptions3);
$form = $builder->getForm();
$form->handleRequest($this->get('request'));
return $form;
}
/**
* Build a form to create a project
* @return form
*/
protected function getFormCreateProjectInformation()
{
$project = new Project();
$builder = $this->createFormBuilder($project);
// Add form fields
$name = array('label' => 'Project', 'constraints' => array(new NotBlank, new Length(array('min' => 5, 'max' => 100))));
$builder->add('name', 'text', $name);
$engagement = array('label' => 'Engagement', 'constraints' => array(new NotBlank, new Length(array('min' => 5, 'max' => 100))));
$builder->add('engagement', 'text', $engagement);
$engagementManager = array('label' => 'Engagement Manager', 'constraints' => array(new NotBlank, new Length(array('min' => 5, 'max' => 100))));
$builder->add('engagementManager', 'text', $engagementManager);
$projectManager = array('label' => 'Project Manager', 'constraints' => array(new NotBlank, new Length(array('min' => 5, 'max' => 100))));
$builder->add('projectManager', 'text', $projectManager);
$startingWeek = array('label' => 'Starting week', 'constraints' => array(new NotBlank, new Length(array('min' =>1, 'max' => 2))));
$builder->add('startingWeek', 'text', $startingWeek);
$version = array('label' => 'Version', 'constraints' => array(new NotBlank, new Length(array('min' => 5, 'max' => 15))));
$builder->add('version', 'text', $version);
$versionDate = array('label' => 'Version Date', 'constraints' => array(new NotBlank));
$builder->add('versionDate', 'date', $versionDate);
$weekConfig = array('label' => 'Week config', 'constraints' => array(new NotBlank, new Length(array('min' =>1, 'max' => 2))));
$builder->add('weekConfig', 'text', $weekConfig);
$submitOptions = array('label' => 'Add the project', 'attr'=>array('class'=>'btn'));
$builder->add('validate', 'submit', $submitOptions);
// Get form object
$form = $builder->getForm();
if (!$this->confirm){
$form->handleRequest($this->get('request'));
}
return $form;
}
/**
* Build a form to display the selected project
* @param type $id
* @return form
*/
protected function getFormDisplayProject($project)
{
//Get selected projects
//$em = $this->getDoctrine()->getManager();
//$rep = $em->getRepository('ATSCapacityPlanBundle:Project');
//$projectToDisplay = $rep->find($id);
$builder = $this->createFormBuilder($project);
// Add form fields
$name = array('label' => 'Project', 'constraints' => array(new NotBlank, new Length(array('min' => 5, 'max' => 100))));
$builder->add('name', 'text', $name);
$engagement = array('label' => 'Engagement', 'constraints' => array(new NotBlank, new Length(array('min' => 5, 'max' => 100))));
$builder->add('engagement', 'text', $engagement);
$engagementManager = array('label' => 'Engagement Manager', 'constraints' => array(new NotBlank, new Length(array('min' => 5, 'max' => 100))));
$builder->add('engagementManager', 'text', $engagementManager);
$projectManager = array('label' => 'Project Manager', 'constraints' => array(new NotBlank, new Length(array('min' => 5, 'max' => 100))));
$builder->add('projectManager', 'text', $projectManager);
$startingWeek = array('label' => 'Starting week', 'constraints' => array(new NotBlank, new Length(array('min' =>1, 'max' => 2))));
$builder->add('startingWeek', 'text', $startingWeek);
$version = array('label' => 'Version', 'constraints' => array(new NotBlank, new Length(array('min' => 5, 'max' => 15))));
$builder->add('version', 'text', $version);
$versionDate = array('label' => 'Version Date', 'constraints' => array(new NotBlank));
$builder->add('versionDate', 'date', $versionDate);
$weekConfig = array('label' => 'Week config', 'constraints' => array(new NotBlank, new Length(array('min' =>1, 'max' => 2))));
$builder->add('weekConfig', 'text', $weekConfig);
$submitOptions = array('label' => 'Update project','attr'=>array('class'=>'btn'));
$builder->add('validate', 'submit', $submitOptions);
// Get form object
$form = $builder->getForm();
if (!$this->confirm){
$form->handleRequest($this->get('request'));
}
return $form;
protected function getFormAssumptions($project)
{
//Get selected projects
//$em = $this->getDoctrine()->getManager();
//$rep = $em->getRepository('ATSCapacityPlanBundle:Project');
//$projectToDisplay = $rep->find($id);
$assumptionsToDisplay = $project->getAssumptions();
$builder = $this->createFormBuilder();
// Add form fields
$i = 0;
foreach ($assumptionsToDisplay as $assump){
$i++;
$assumption = array('label'=>'Assumption : '.$i, 'required'=>'false', 'data'=>$assump->getText(), 'constraints' => array(new Length(array('min' => 0, 'max' => 100))));
$builder->add('assumption'.$i, 'text', $assumption);
}
$blankAssumption = array('required'=>'false');
$builder->add('assumption', 'text', $blankAssumption);
$createAssumption = array('label' => 'Add Assumption','attr'=>array('class'=>'btn'));
$builder->add('add', 'submit', $createAssumption);
// Get form object
$form = $builder->getForm();
if (!$this->confirm){
$form->handleRequest($this->get('request'));
}
return $form;
}
protected function getFormServices($project)
{
//Get selected projects
//$em = $this->getDoctrine()->getManager();
//$rep = $em->getRepository('ATSCapacityPlanBundle:Project');
$project = $project;//$rep->find($id);
//$ser = new \ATS\CapacityPlanBundle\Entity\Service();
$builder = $this->createFormBuilder();
// Get All Categories
$em2 = $this->getDoctrine()->getManager();
$rep2 = $em2->getRepository('ATSCapacityPlanBundle:Category');
$categories = $rep2->findAll();
// Get All Priorities
$em3 = $this->getDoctrine()->getManager();
$rep3 = $em3->getRepository('ATSCapacityPlanBundle:Priority');
$priorities = $rep3->findAll();
// Get Project's Services
$services = $project->getServices();
// Add form fields
$i = 0;
foreach ($services as $serv){
$i++;
$service = array('label'=>'Service : '.$i, 'required'=>'false', 'data'=>$serv->getName(), 'constraints' => array(new Length(array('min' => 0, 'max' => 100))));
$builder->add('service'.$i, 'text', $service);
$builder->add('category'.$i, 'entity', array(
'class' => 'ATSCapacityPlanBundle:Category',
'property' => 'name',
'data' => $project->getCategorie(),
'choices' => $categories,
'attr' => array('class'=>'btn')));
$builder->add('priority'.$i, 'entity', array(
'class' => 'ATSCapacityPlanBundle:Priority',
'property' => 'name',
'choices' => $priorities,
'data' => $project->getPriority(),
'attr' => array('class'=>'btn')));
}
$blankServiceName = array('required'=>'false');
$builder->add('serviceName', 'text', $blankServiceName);
$builder->add('category', 'entity', array(
'class' => 'ATSCapacityPlanBundle:Category',
'property' => 'name',
'choices' => $categories,
'attr' => array('class'=>'btn')));
$builder->add('priority', 'entity', array(
'class' => 'ATSCapacityPlanBundle:Priority',
'property' => 'name',
'choices' => $priorities,
'attr' => array('class'=>'btn')));
$blankServiceDescription = array('required'=>'false');
$builder->add('serviceDescription', 'text', $blankServiceDescription);
$createService = array('label' => 'Add Service','attr'=>array('class'=>'btn'));
$builder->add('add', 'submit', $createService);
// Get form object
$form = $builder->getForm();
if (!$this->confirm){
$form->handleRequest($this->get('request'));
}
return $form;
}
} |
Partager