/**
  * @Route("/add/{provider}", name="application_add_to_provider",options={"expose"=true})
  * @Template("AppBundle:Application:add.html.twig")
  * @param Provider $provider
  * @ParamConverter("provider", class="AppBundle:Provider")
  * @return Response
  */
 public function addAction(Request $request, Provider $provider)
 {
     $app = new Application();
     $app->setProvider($provider);
     /** @var Security $context */
     $context = $this->get('security.context');
     $form = $this->createForm(new ApplicationType($context), $app);
     $form->handleRequest($request);
     if ($form->isValid()) {
         $em = $this->getDoctrine()->getManager();
         $em->persist($app);
         $em->flush();
         return $this->redirect($this->generateUrl('provider_show', array('provider' => $provider->getId())));
     }
     return array('form' => $form->createView());
 }
Example #2
0
 /**
  * Add application
  *
  * @param \AppBundle\Entity\Application $application
  *
  * @return Provider
  */
 public function addApplication(\AppBundle\Entity\Application $application)
 {
     $this->applications[] = $application;
     $application->setProvider($this);
     return $this;
 }
Example #3
0
 private function createApplications($provider, $projects, $users, $projectString, $fundraiserString, $dateDemandeString, $amountString, $responseString, $dateResponseString, $reasonString)
 {
     if ($projectString == null) {
         return;
     }
     if ($projectString == '') {
         return;
     }
     if ($fundraiserString == null) {
         return;
     }
     if ($fundraiserString == '') {
         return;
     }
     $projects_keys = explode(', ', $projectString);
     $fundraisers_keys = explode(', ', $fundraiserString);
     preg_match('/\\b\\d{2}[-.]?\\d{2}[-.]?\\d{4}\\b/', $dateDemandeString, $date_keys);
     $response_keys = explode(', ', $responseString);
     $amount_keys = explode(', ', $amountString);
     preg_match('/\\b\\d{2}[-.]?\\d{2}[-.]?\\d{4}\\b/', $dateResponseString, $date_response_keys);
     for ($i = 0; $i < count($projects_keys); $i++) {
         $app = new Application();
         $app->setProvider($provider);
         if (isset($fundraisers_keys[$i])) {
             $app->setFundraiser($users[$fundraisers_keys[$i]]);
         }
         if (isset($projects_keys[$i])) {
             $app->setProject($projects[$projects_keys[$i]]);
         }
         if (isset($date_keys[$i])) {
             $app->setAskDate(\DateTime::createFromFormat('d.m.Y', $date_keys[$i]));
         }
         if (isset($date_response_keys[$i])) {
             $app->setResponseDate(\DateTime::createFromFormat('d.m.Y', $date_response_keys[$i]));
         }
         if (isset($response_keys[$i])) {
             switch ($response_keys[$i]) {
                 case 'NON':
                     $app->setResponse(Application::RESPONSE_NO);
                     break;
                 case 'OUI':
                     $app->setResponse(Application::RESPONSE_YES);
                     break;
                 case 'En attente':
                     $app->setResponse(Application::RESPONSE_WAITING);
                     break;
             }
         }
         $app->setResponseMotivation($reasonString);
         if (isset($amount_keys[$i])) {
             $array = array();
             preg_match_all('!\\d+!', $amount_keys[$i], $array);
             // print_r($array);
             $number = '';
             foreach ($array[0] as $piece) {
                 $number = $number . $piece;
             }
             echo $number . PHP_EOL;
             $app->setAmount(floatval($number));
         }
         $app->setStatus(Application::STATUS_CLOSED);
     }
 }