/**
  * Creates a new Carpooling entity.
  *
  * @Route("/covoiturage/create", name="social_carpooling_create")
  * @Method("POST")
  * @Template("CharlestownCarpoolingBundle:Carpooling:new.html.twig")
  */
 public function createAction(Request $request)
 {
     $entity = new Carpooling();
     $em = $this->getDoctrine()->getManager();
     $entity->setStartPlace($request->get('depart'));
     $entity->setEndPlace($request->get('arrivé'));
     if ($request->get('recurrent') == "oui") {
         $hour = new \DateTime();
         $hour->setTime(substr($request->get('hour'), 0, 2), substr($request->get('hour'), 3, 2));
         $entity->setDateTravel($hour);
         if ($request->get('monday') == "on") {
             $entity->setMonday(true);
         } else {
             $entity->setMonday(false);
         }
         if ($request->get('tuesday') == "on") {
             $entity->setTuesday(true);
         } else {
             $entity->setTuesday(false);
         }
         if ($request->get('wednesday') == "on") {
             $entity->setWednesday(true);
         } else {
             $entity->setWednesday(false);
         }
         if ($request->get('thursday') == "on") {
             $entity->setThursday(true);
         } else {
             $entity->setThursday(false);
         }
         if ($request->get('friday') == "on") {
             $entity->setFriday(true);
         } else {
             $entity->setFriday(false);
         }
         if ($request->get('saturday') == "on") {
             $entity->setSaturday(true);
         } else {
             $entity->setSaturday(false);
         }
         if ($request->get('sunday') == "on") {
             $entity->setSunday(true);
         } else {
             $entity->setSunday(false);
         }
         $entity->setRecurrent(true);
     } else {
         $entity->setDateTravel($request->get("datetime"));
         $entity->setRecurrent(false);
     }
     $entity->setDriver($this->getUser());
     $em->persist($entity);
     $em->flush();
     return $this->redirect($this->generateUrl('social_my_carpooling'));
 }
Example #2
0
 /**
  * @param $spot
  * Efface toutes les données plus vielle que today
  */
 static function deleteOldData($spot, $em)
 {
     // On check toutes les notesDate
     $listePrecedenteNotes = $spot->getNotesDate();
     if ($listePrecedenteNotes != null && count($listePrecedenteNotes) > 0) {
         //la liste n'est pas vide
         $today = new \DateTime('now');
         $today->setTime(0, 0, 0);
         foreach ($listePrecedenteNotes as $precedenteNotes) {
             if ($precedenteNotes->getDatePrev() < $today) {
                 // avant today -> on efface
                 $em->remove($precedenteNotes);
             }
         }
         $em->flush();
     }
 }
Example #3
0
 public function indicadores()
 {
     $date = new \DateTime();
     $date2 = new \DateTime();
     $date->setTime(00, 00);
     $date2->setTime(23, 59);
     $parametros = array('propietario' => 'Uf', 'columna' => 'fecha', 'date1' => $date, 'date2' => $date2);
     $valorUf = $this->listar->obtenerInformacionSoloFecha($parametros);
     if ($valorUf == null) {
         $fuente = file_get_contents('http://www.bancoestado.cl/bancoestado/indiceseconomicos/indicadores.asp');
         if ($fuente == false) {
             $uf = "NA";
             return uf;
         }
         $tipo = 'uf';
         $limite = 'UF</a></font></td>';
         $domain = strstr($fuente, $limite);
         $domain = $domain;
         switch ($tipo) {
             case "uf":
                 $domain = strip_tags($domain);
                 $domain = split('\\n', $domain);
                 $uf = (double) str_replace(array("\r\n", "\n", "\r", "\t", "&", "UF", " ", "\$", "."), "", $domain[0]);
                 $informacion = array('valorUf' => $uf, 'fecha' => new \DateTime());
                 $this->addLocation->salvarUf($informacion);
                 return $uf;
                 break;
             case "dolar":
                 $domain = strip_tags($domain);
                 $domain = explode('\\n', $domain);
                 return str_replace(array("\r\n", "\n", "\r", "\t", "&", "lar Observado", " ", "\$"), "", $domain[0]);
                 break;
             case 2:
                 echo "i equals 2";
                 break;
         }
     } else {
         foreach ($valorUf as $valorUf) {
             $aux = $valorUf->getValorUf();
         }
         return $aux;
     }
 }
Example #4
0
 /**
  * @Route("/addincome",name= "addincome")
  * @Method("POST")
  * @Template()
  * */
 public function addincomeAction(Request $request)
 {
     $billpg = $this->container->getParameter('cod.billpg');
     //4
     $em = $this->getDoctrine()->getManager();
     $saleid = $this->get('request')->request->get('saleid');
     $value = $this->get('request')->request->get('value');
     $parc = $this->get('request')->request->get('parc');
     $tpay = $this->get('request')->request->get('tpay');
     $date = $this->get('request')->request->get('date');
     $dat = new \DateTime($date);
     $dat->setTime(date("H"), date("i"));
     $tpayment = $em->getRepository('UerptpaymentBundle:tpayment')->find($tpay);
     $valueb = $value / $parc;
     $tax = $tpayment->getTax() * $valueb / 100;
     $valuel = $valueb - $tax;
     $status = $tpayment->getDefaultstatus();
     $idays = $tpayment->getDays();
     // $dat->modify("+".$idays." days");
     $entitya = $em->getRepository('UerpBankBundle:BankAccount')->find($tpayment->getBank());
     if (!$entitya) {
         throw $this->createNotFoundException('Unable to find account entity.');
     }
     $bal = 0.0;
     for ($i = 0; $i < $parc; $i++) {
         $datd = new \DateTime($date);
         $datd->setTime(date("H"), date("i"));
         $p = $i + 1;
         $addday = $idays * $p;
         $datd->modify("+" . $addday . " days");
         // dump($da); die;
         $incomes = new incomes();
         $incomes->setSaleId($saleid);
         $incomes->setValueb($valueb);
         $incomes->setValuel($valuel);
         $bal = $bal + $valuel;
         $incomes->setTax($tax);
         $incomes->setBank($entitya);
         $incomes->setDate($datd);
         $incomes->setParc($p . "/" . $parc);
         $incomes->setStatus($status);
         $incomes->setTpayment($tpayment);
         $em->persist($incomes);
     }
     if ($status->getId() == $billpg) {
         $balance = $entitya->getBalance() + $bal;
         $entitya->setBalance($balance);
     }
     $em->flush();
     $response = new Response();
     $response->setContent(json_encode(array('id' => $incomes->getId())));
     $response->headers->set('Content-Type', 'application/json');
     return $response;
 }
Example #5
0
 /**
  * Create TrackAltinv entities via ajax.
  *
  * @Route("/add", name="ajax_trackaltinv_create")
  * @Method("POST")
  */
 public function ajaxCreateTrackAltinv(Request $request)
 {
     $mes = $request->get('mes');
     if ($mes < 10) {
         $mes = "0" . $mes;
     }
     //$fecha= 'd-'.$mes.'-y h:i:s';
     $fecha = new \DateTime();
     $fecha->setDate(date('Y'), $mes, 01);
     $fecha->setTime(0, 0, 0);
     $value = $request->get('valor');
     $em = $this->getDoctrine()->getManager();
     $id_fieldsaltinv = $em->getReference('BL\\SGIBundle\\Entity\\FieldsAltinv', $request->get('id_fieldsaltinv'));
     $id_altinv = $em->getReference('BL\\SGIBundle\\Entity\\Altinv', $request->get('id_altinv'));
     /*antes que nada buscar si ya esta el registro, si esya modificar*/
     $object = $em->getRepository('SGIBundle:TrackAltinv')->findOneBy(array('idAltinv' => $id_altinv, 'idFieldsTrackAltinv' => $id_fieldsaltinv, 'datetime' => $fecha));
     if (count($object) == 0) {
         $object = new TrackAltinv();
     }
     $object->setIdAltinv($id_altinv);
     //objeto de tipo altinv
     $object->setIdFieldsTrackAltinv($id_fieldsaltinv);
     //objeto de tipo fields altinv
     $object->setDatetime($fecha);
     $object->setValue($value);
     $em->persist($object);
     $em->flush();
     return new Response($object->getId());
 }
 /**
  * Check different data-transformers
  * /fp_js_form_validator/javascript_unit_test/transformers/{isValid}/{js}
  *
  * @param \Symfony\Component\HttpFoundation\Request $request
  * @param                                           $isValid
  * @param                                           $js
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function transformersAction(Request $request, $isValid, $js)
 {
     $date = new \DateTime();
     $date->setDate(2009, 4, 7);
     $date->setTime(21, 15);
     $choices = array('m' => 'male', 'f' => 'female');
     $form = $this->createFormBuilder(array('date' => $date, 'time' => $date, 'datetime' => $date, 'checkbox' => (bool) $isValid, 'radio' => (bool) $isValid, 'ChoicesToValues' => array('m', 'f'), 'ChoiceToValue' => 'f', 'ChoicesToBooleanArray' => array('m', 'f'), 'ChoiceToBooleanArray' => 'f', 'repeated' => 'asdf'), array('js_validation' => (bool) $js))->add('date', 'date', array('constraints' => array(new Date())))->add('time', 'time', array('constraints' => array(new Time())))->add('datetime', 'datetime', array('constraints' => array(new DateTime())))->add('checkbox', 'checkbox', array('constraints' => array(new True(array('message' => 'checkbox_false')), new False(array('message' => 'checkbox_true')))))->add('radio', 'radio', array('constraints' => array(new True(array('message' => 'radio_false')), new False(array('message' => 'radio_true')))))->add('ChoicesToValues', 'choice', array('multiple' => true, 'choices' => $choices, 'constraints' => array(new Choice(array('multiple' => true, 'choices' => array_keys($choices), 'maxMessage' => 'multiple_choices', 'max' => $isValid ? 10 : 1)))))->add('ChoiceToValue', 'choice', array('multiple' => false, 'choices' => $choices, 'constraints' => array(new Choice(array('multiple' => false, 'choices' => $isValid ? array_keys($choices) : array('a', 'b'), 'message' => 'single_choice')))))->add('ChoicesToBooleanArray', 'choice', array('expanded' => true, 'multiple' => true, 'choices' => $choices, 'constraints' => array(new Choice(array('multiple' => true, 'choices' => $isValid ? array_keys($choices) : array('m', 'c'), 'multipleMessage' => 'multiple_boolean_choices')))))->add('ChoiceToBooleanArray', 'choice', array('expanded' => true, 'multiple' => false, 'choices' => $choices, 'constraints' => array(new Choice(array('multiple' => false, 'choices' => $isValid ? array_keys($choices) : array('m', 'c'), 'message' => 'single_boolean_choice')))))->add('repeated', 'repeated', array('type' => 'text', 'invalid_message' => 'not_equal', 'first_options' => array('label' => 'Field'), 'second_options' => array('label' => 'Repeat Field', 'data' => $isValid ? 'asdf' : 'zxcv')))->getForm();
     $form->handleRequest($request);
     return $this->render('DefaultTestBundle:FunctionalTests:index.html.twig', array('form' => $form->createView()));
 }
Example #7
0
 /**
  * @Route("/issue/edit/{id}/{project_id}", name="_editIssues")
  * @Template("TrackersBundle:Issues:edit.html.twig")
  */
 public function editAction($id, $project_id)
 {
     $issue = new Project_issues();
     $repositorys = $this->getDoctrine()->getRepository('TrackersBundle:Project_issues');
     if ($this->getRequest()->getMethod() == 'POST') {
         $requestData = $this->getRequest()->request;
         $form = $requestData->get('form');
         $assignedTo = $requestData->get('assigned_to');
         $date = $requestData->get('date');
         $time = $time = '0:0:0';
         // $requestData->get('time');
         $arr_date = explode('-', $date);
         $arr_time = explode(':', $time);
         $date_time = new \DateTime("now");
         $date_time->setDate($arr_date[0], $arr_date[1], $arr_date[2]);
         $date_time->setTime($arr_time[0], $arr_time[1], $arr_time[2]);
         $issue = $repositorys->find($id);
         $issue->setTitle($form['title']);
         $issue->setDescription($form['description']);
         $issue->setEndTime($date_time);
         $issue->setStatus($form['status']);
         $issue->setModified(new \DateTime("now"));
         $issue->setProjectId($project_id);
         $issue->setCreatedBy($this->getUser()->getId());
         $em = $this->getDoctrine()->getManager();
         $em->persist($issue);
         $em->flush();
         $repository_attachments = $this->getDoctrine()->getRepository('TrackersBundle:Project_issue_assignments');
         $attachments = $repository_attachments->findBy(array('issueId' => $issue->getId()));
         // delete user attachments
         if (!empty($attachments)) {
             foreach ($attachments as $attachment) {
                 $repository_attachments = $this->getDoctrine()->getRepository('TrackersBundle:Project_issue_assignments');
                 $em = $this->getDoctrine()->getManager();
                 $user_attachments = $repository_attachments->find($attachment->getId());
                 $em->remove($user_attachments);
                 $em->flush();
             }
         }
         $users_activity = new Users_activity();
         $users_activity->setUserId($this->getUser()->getId());
         $users_activity->setParentId($project_id);
         $users_activity->setItemId($issue->getId());
         $users_activity->setTypeId(5);
         $users_activity->setCreatedAt(new \DateTime("now"));
         $em->persist($users_activity);
         $em->flush();
         if (!empty($assignedTo)) {
             foreach ($assignedTo as $assigned) {
                 $project_issue_assignments = new Project_issue_assignments();
                 $project_issue_assignments->setUserId($assigned);
                 $project_issue_assignments->setIssueId($issue->getId());
                 $em->persist($project_issue_assignments);
                 $em->flush();
                 $repository = $this->getDoctrine()->getRepository('TrackersBundle:UserDetail');
                 $users = $repository->findBy(array('user_id' => $this->getUser()->getId()));
                 $user = $users[0];
                 $notifications = new Notifications();
                 $notifications->setUserId($assigned);
                 $notifications->setIssueId($issue->getId());
                 $notifications->setProjectId($project_id);
                 $notifications->setCreated(new \DateTime("now"));
                 $notifications->setIsRead(false);
                 $notifications->setText('You have reassign issue with title ' . $form['title'] . ' from ' . $user->getFirstname() . ' ' . $user->getLastname());
                 $em->persist($notifications);
                 $em->flush();
             }
         }
         $this->get('session')->getFlashBag()->add('notice', 'Issue is successfully edited!');
     }
     $em = $this->getDoctrine()->getEntityManager();
     $query = $em->createQuery("SELECT n.firstname , n.lastname ,n.user_id FROM TrackersBundle:UserDetail n, TrackersBundle:User_projects u WHERE  u.userId = n.user_id AND u.projectId = :project_id")->setParameter('project_id', $project_id);
     $entities = $query->getResult();
     $arr = array();
     $issues_id = $repositorys->find($id);
     // ---- load array mutil select
     $repository = $this->getDoctrine()->getRepository('TrackersBundle:Project_issue_assignments');
     $assignments = $repository->findBy(array('issueId' => $id));
     foreach ($entities as $post) {
         $is_select = false;
         foreach ($assignments as $assign) {
             if ($post['user_id'] == $assign->getUserId()) {
                 $is_select = true;
                 break;
             }
         }
         $arr[] = array('id' => $post['user_id'], 'fullName' => $post['firstname'] . " " . $post['lastname'], 'selected' => $is_select);
     }
     $assignedToOld = $issues_id->getassignedTo();
     // set form
     $issue->setTitle($issues_id->getTitle());
     $issue->setDescription($issues_id->getDescription());
     $issue->setStatus($issues_id->getStatus());
     $form = $this->createFormBuilder($issue)->add('title', 'text', array('label' => 'Tile', 'required' => true))->add('description', 'textarea', array('required' => false, 'label' => 'Description', 'attr' => array('class' => 'editor', 'id' => 'editor')))->add('status', 'choice', array('choices' => array('OPEN' => 'OPEN', 'HOLD' => 'HOLD', 'INPROGRESS' => 'INPROGRESS', 'CLOSED' => 'CLOSED', 'FINISHED' => 'FINISHED'), 'preferred_choices' => array($issues_id->getStatus()), 'label' => 'Status'))->getForm();
     return array('form' => $form->createView(), 'project_id' => $project_id, 'assignedTo' => $assignedToOld, 'assignedtos' => $arr, 'endtime' => $issues_id->getEndTime(), 'date' => $issues_id->getEndTime()->format('Y-m-d'), 'time' => $issues_id->getEndTime()->format('H:i:s'));
 }
 /** Part 3.4, share ride (redirect to part 2) -------------------------
  * @Route("/share/{swissDate}", name="tixiapi_dispo_dailyplan_share")
  * @Method({"GET","POST"})
  * @param Request $request
  * @param mixed $swissDate
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function getDailyPlanEditShareAction(Request $request, $swissDate)
 {
     $errors = array();
     $tr = $this->get('translator');
     // check date
     $date = $this->swissDateToDate($swissDate);
     $yesterday = new \DateTime('yesterday');
     $yesterday->setTime(0, 0, 0);
     if ($date <= $yesterday) {
         $errors[] = $tr->trans('dailyplan.error.read.only');
     }
     $errors[] = $tr->trans('dailyplan.error.share.wip');
     // check errors
     $errorMessage = null;
     if (count($errors > 0)) {
         foreach ($errors as $error) {
             $errorMessage .= "<p>" . $error . "</p>";
         }
     }
     $errorMessage = null !== $errorMessage ? "?errorMessage=" . urlencode($errorMessage) : null;
     // redirect to GUI
     return $this->redirect($this->generateUrl('tixiapi_dispo_dailyplan_edit_swissdate', array('swissDate' => $swissDate)) . $errorMessage);
 }
Example #9
0
    public function __construct()
    {
        $this->roles = new ArrayCollection();

        $this->isActive = true;
        $this->salt = md5(uniqid(null, true));

        $workHoursStart = new \DateTime();
        $workHoursStart->setTime(0, 0, 0);

        $this->workHourStart = $workHoursStart;

        $workHoursEnd = new \DateTime();
        $workHoursEnd->setTime(0, 0, 0);

        $this->workHourEnd = $workHoursEnd;
    }
 /**
  * @param $userId
  * @param $workTimeId
  * @param $endDateRequest
  * @param $durationRequest
  * @param $descriptionRequest
  * @return WorkTimeDTO
  * @throws ValidationException
  * @throws WorkTimeNotActiveException
  * @throws WorkTimeNotFoundException
  */
 public function stopWorkTime($userId, $workTimeId, $endDateRequest, $durationRequest, $descriptionRequest)
 {
     $workTime = $this->workTimeRepository->findWorkTimeByUserAndId($userId, $workTimeId);
     if ($workTime === null) {
         throw new WorkTimeNotFoundException();
     }
     if ($workTime->getEndDate() !== null) {
         throw new WorkTimeNotActiveException();
     }
     $validations = array(array($endDateRequest, array(new NotNull(), new DateTime()), 'endDate'), array($durationRequest, array(new NotNull(), new Regex(array('value' => '/([0-9]|0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]/'))), 'duration'), array($descriptionRequest, array(new Length(array('min' => 5, 'max' => '255')))));
     $validationErrors = new ConstraintViolationList();
     foreach ($validations as $values) {
         $errors = $this->validator->validate($values[0], $values[1]);
         if ($errors->count() > 0) {
             foreach ($errors as $error) {
                 /* @var $error ConstraintViolationInterface */
                 $validationErrors->add(new ConstraintViolation($error->getMessage(), $error->getMessageTemplate(), $error->getMessageParameters(), $error->getRoot(), $values[2], $error->getInvalidValue()));
             }
         }
     }
     if ($validationErrors->count() > 0) {
         throw new ValidationException($validationErrors);
     }
     $duration = new \DateTime();
     $durationRequest = explode(':', $durationRequest);
     $duration->setTime($durationRequest[0], $durationRequest[1], 0);
     $endDate = new \DateTime($endDateRequest);
     $this->workTimeRepository->stopWorkTime($workTime, $endDate, $duration, $descriptionRequest);
     return WorkTimeDTO::withEntity($workTime);
 }
Example #11
0
 public function setZoneAction(Request $request)
 {
     $name = $request->request->get('zonename');
     if (!empty($name)) {
         if ($this->zoneValidator($name) != 0) {
             return $this->redirectToRoute('home_error', array('error_name' => 'invalid_zone'));
         }
         $user = $this->get('security.token_storage')->getToken()->getUser();
         $user->setZone($name);
         $user->setPkey(Util\SSIDEncryptor::encode($name));
         $user->setSkey(Util\PassGenerator::generateStrongPassword());
         $em = $this->getDoctrine()->getManager();
         $em->persist($user);
         $newPkg = new Entity\data_package($user);
         $newPkg->setKbytes(10000000);
         $oFirst = new \DateTime('first day of this month');
         $oLast = new \DateTime('last day of this month');
         $oLast->setTime(23, 59, 59);
         $newPkg->setStart($oFirst);
         $newPkg->setEnd($oLast);
         $em->persist($newPkg);
         $em->flush();
         // Creating default `Unregistered` user
         $unregisteredUser = new Entity\slave_user("FFFFFFFFFFFF", $user, "UNREGISTERED", 0, 1);
         $em->persist($unregisteredUser);
         $em->flush();
         return $this->redirect($this->generateUrl('settings_packages', array(), false));
     } else {
         return $this->render('setzone/base.html.twig', array('zoneName' => ''));
     }
 }