/**
  * @Route("/api/addNewEmployee", name="_apiAddNewEmployee")
  */
 public function apiAddNewEmployeeAction(Request $request)
 {
     $session = $request->getSession();
     $time_left = self::getTimerValue($session);
     // if timer is not expired - add to db
     if ($time_left) {
         // add to db
         $employee = new Employee();
         $employee->setLastName($request->request->get('last_name'));
         $employee->setFirstName($request->request->get('first_name'));
         $employee->setMiddleName($request->request->get('middle_name'));
         $birth_date = \DateTime::createFromFormat('Y-m-d', $request->request->get('bdate'));
         $employee->setBirthDate($birth_date);
         $employee->setAddress($request->request->get('address'));
         $employee->setPhone($request->request->get('phone'));
         $employee->setEmail($request->request->get('email'));
         $employee->setBio($request->request->get('bio'));
         $em = $this->getDoctrine()->getManager();
         $em->persist($employee);
         $em->flush();
     }
     if (!$time_left) {
         $response = new Response(json_encode(array('code' => 1, 'message' => 'Неможливо додати дані, так як вийшов час, відведений на заповнення форми')));
     } else {
         $response = new Response(json_encode(array('code' => 0, 'message' => 'Успішно виконано')));
     }
     $response->headers->set('Content-Type', 'application/json');
     return $response;
 }
示例#2
0
 /**
  * Set employee
  *
  * @param \AppBundle\Entity\Employee $employee
  *
  * @return User
  */
 public function setEmployee(\AppBundle\Entity\Employee $employee = null)
 {
     if ($employee instanceof Employee) {
         $employee->setUser($this);
     }
     $this->employee = $employee;
     return $this;
 }
 /**
  * @dataProvider employeeProvider
  */
 public function testSerializeEmployee(Employee $employee)
 {
     $serializedEmployee = Utils::invokeMethod(new EmployeeController(), 'serializeEmployee', array($employee));
     $this->assertInternalType('array', $serializedEmployee);
     $this->assertEquals($employee->getFirstname(), $serializedEmployee['firstname']);
     $this->assertEquals($employee->getUser()->getEmail(), $serializedEmployee['email']);
     $this->assertEquals($employee->getUser()->hasRole('ROLE_TEAM_LEADER'), $serializedEmployee['isTeamLeader']);
     $this->assertEquals($employee->getUser()->hasRole('ROLE_MANAGER'), $serializedEmployee['isManager']);
 }
示例#4
0
 private function createEmployee(array $serializedEmployee)
 {
     $userManager = $this->get('fos_user.user_manager');
     $employee = new Employee();
     $employee->setUser($userManager->createUser());
     $employee->getUser()->setPlainPassword($this->get('fos_user.util.token_generator')->generateToken());
     $this->updateEmployeeObject($employee, $serializedEmployee);
     $userManager->updateUser($employee->getUser(), false);
     $this->validateEmployee($employee);
     $this->getDoctrine()->getManager()->persist($employee);
     $this->getDoctrine()->getManager()->flush();
     return $employee;
 }
 private function getEntities()
 {
     $p = new Person('Sergio', 'Santoro');
     $entities[] = $p;
     $p = new Customer('Sergio', 'Lesta');
     $p->setShippingAddress('This is an address');
     $entities[] = $p;
     $p = new Employee('Sergio', 'Franchi');
     $p->setDepartement('machinery');
     $entities[] = $p;
     $p = new Engineer('Alberto', 'Grafi');
     $p->setDepartement('machinery');
     $p->setMainSkill('desing');
     $entities[] = $p;
     $p = new Manager('Sergio', 'Grafi');
     $p->setDepartement('recruiting');
     $p->setYearsOfExperience(5);
     $entities[] = $p;
     return $entities;
 }
示例#6
0
 /**
  * @Given /^employee "([^"]*)" "([^"]*)" who joined "([^"]*)" years ago$/
  */
 public function employeeWhoJoinedYearsAgo($fname, $lname, $years)
 {
     $em = $this->get('em');
     $employee = new Employee();
     $now = new \DateTime();
     $yearsAgo = $now->modify('-' . $years . ' years');
     $employee->setBirthdate($now);
     $employee->setFirstname($fname);
     $employee->setLastname($lname);
     $employee->setJoinedAt($yearsAgo);
     $em->persist($employee);
     $em->flush();
 }
示例#7
0
 /**
  * Tests if a new User instance is created when no User is set
  */
 public function testGetUser()
 {
     $employeeWithoutUser = new Employee();
     $this->assertInstanceOf(User::class, $employeeWithoutUser->getUser());
     $this->assertNull($employeeWithoutUser->getUser()->getId());
 }
示例#8
0
 protected function configureFormFields(FormMapper $formMapper)
 {
     $formMapper->tab('general')->with('options', array('class' => 'col-md-4'))->add('eintritt', 'date', array('widget' => 'single_text', 'required' => false))->add('austritt', 'date', array('widget' => 'single_text', 'required' => false))->add('ahv')->add('surename')->add('forename')->add('street')->add('street2')->add('zip')->add('city')->add('country', 'country', array('preferred_choices' => array('CH')))->end()->with('options2', array('class' => 'col-md-4'))->add('iban')->add('bank')->add('birthday', 'birthday', array('widget' => 'single_text'))->add('children')->add('gender', 'choice', array('choices' => Employee::getGenderChoices(), 'required' => false, 'placeholder' => 'choose_gender', 'empty_data' => null))->add('childBenefit', 'money', array('label' => 'child_benefit', 'required' => false, 'currency' => 'CHF'))->add('bvg', 'money', array('required' => false, 'currency' => 'CHF'))->end()->with('options3', array('class' => 'col-md-4'))->add('salaryType', 'choice', array('label' => 'salary_type', 'required' => false, 'choices' => Employee::getSalaryTypeChoices()))->add('hourlyRate', 'money', array('label' => 'hourly_rate', 'required' => false, 'currency' => 'CHF'))->add('proratedBonus13Month', 'money', array('label' => 'prorated_bonus_13_month', 'required' => false, 'currency' => 'CHF'))->add('proratedBonusPublicHoliday', 'money', array('label' => 'prorated_bonus_public_holiday', 'required' => false, 'currency' => 'CHF'))->add('proratedBonusVacation', 'money', array('label' => 'prorated_bonus_vacation', 'required' => false, 'currency' => 'CHF'))->add('monthlyRate', 'money', array('label' => 'monthly_rate', 'required' => false, 'currency' => 'CHF'))->add('annualVacationDays', null, array('label' => 'annual_vacation_days', 'required' => false))->add('totalVacationDays', 'text', array('label' => 'total_vacation_days', 'read_only' => true, 'disabled' => true, 'required' => false))->add('getVacationDaysLeftCurrentYear', 'text', array('label' => 'vacation_days_left_year', 'read_only' => true, 'disabled' => true, 'required' => false))->end()->end();
 }