public function getJobsAction(Request $request)
 {
     $time = explode("-", $request->query->get('date'));
     $date = new \DateTime();
     $date->setDate($time[0], $time[1], $time[2]);
     $user = $this->getUser();
     $response = new JsonResponse();
     $workTimes = $this->container->get('work_time')->getWorkerSchedule($user, $date);
     $response->setData($workTimes);
     return $response;
 }
 /**
  * {@inheritDoc}
  */
 public function load(ObjectManager $manager)
 {
     $config = new Config();
     $config->setCle('currency');
     $config->setValeur('€');
     $manager->persist($config);
     $manager->flush();
     $config2 = new Config();
     $config2->setCle('currentBudget');
     $config2->setValeur('');
     $manager->persist($config2);
     $manager->flush();
     $date = new \DateTime('0-0-0');
     $date->setDate(0, 2, 0);
     $declarationTVA = new DeclarationTva();
     $declarationTVA->setCommentaire("Déclaration de tva poubelle pour les factures un peu douteuses");
     $declarationTVA->setDate($date);
     $declarationTVA->setSoldePrecedent(0);
     $declarationTVA->setSoldeFinal(0);
 }
Beispiel #3
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()));
 }
Beispiel #5
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'));
 }
 /**
  * Renderiza el formulario según la franja seleccionada.
  *
  * @Route("/seleccion/{year}/{mes}/{day}/{horaInicio}/{horaFinal}", name="calendario_seleccion")
  */
 public function seleccionAction($year, $mes, $day, $horaInicio, $horaFinal)
 {
     $data = new \DateTime();
     $data->setDate($year, $mes, 1);
     //Popular el formulario con lo seleccionado del calendario
     $reserva = new Reserva();
     $diaSeleccionado = new \DateTime();
     $diaSeleccionado->setDate($year, $mes, $day);
     $reserva->setHoraInicio($horaInicio);
     $reserva->setHoraFinal($horaFinal);
     $reserva->setDia($diaSeleccionado);
     $form = $this->createCreateForm($reserva);
     return $this->render('calendario/seleccion.html.twig', array('reserva' => $reserva, 'form' => $form->createView()));
 }
 /**
  * Open (build) a new working month and associated working days (~30),
  * shifts (~90) , and driving pools (~1800).
  *
  * @param $year
  * @param $month
  * @return array|null|WorkingMonth
  */
 public function openWorkingMonth($year, $month)
 {
     /** @var WorkingMonthRepository $workingMonthRepository */
     $workingMonthRepository = $this->container->get('workingmonth_repository');
     /** @var WorkingDayRepository $workingDayRepository */
     $workingDayRepository = $this->container->get('workingday_repository');
     /** @var ShiftRepository $shiftRepository */
     $shiftRepository = $this->container->get('shift_repository');
     /** @var ShiftTypeRepository $shiftTypeRepository */
     $shiftTypeRepository = $this->container->get('shifttype_repository');
     /** @var VehicleRepository $vehicleRepository */
     $vehicleRepository = $this->container->get('vehicle_repository');
     /** @var DrivingPoolRepository $drivingPoolRepository */
     $drivingPoolRepository = $this->container->get('drivingpool_repository');
     try {
         $date = new \DateTime();
         $date->setDate($year, $month, 1);
     } catch (\Exception $e) {
         $logger = $this->container->get('logger');
         $logger->error('DispositionManagementImpl->openWorkingMonth: ' . 'illegal date, ' . $e->getMessage());
         return null;
     }
     $workingMonth = WorkingMonth::registerWorkingMonth($date);
     $workingMonth->createWorkingDaysForThisMonth();
     $shiftTypes = $shiftTypeRepository->findAllActive();
     $workingDays = $workingMonth->getWorkingDays();
     /** @var WorkingDay $workingDay */
     foreach ($workingDays as $workingDay) {
         $workingDayRepository->store($workingDay);
         foreach ($shiftTypes as $shiftType) {
             /* make shifts for working day */
             $shift = Shift::registerShift($workingDay, $shiftType, $vehicleRepository->getAmountOfCompanyOwnedVehicles());
             $workingDay->assignShift($shift);
             $shiftRepository->store($shift);
             /* make driving pools for shift */
             $pools = $shift->getAmountOfDrivers();
             for ($i = 0; $i < $pools; $i++) {
                 $drivingPoolRepository->store(DrivingPool::registerDrivingPool($shift));
             }
         }
     }
     $workingMonthRepository->store($workingMonth);
     return $workingMonth;
 }