/** * Transforms a string to an object. * * @param string $jobText * @return Location */ public function reverseTransform($jobText) { $job = $this->em->getRepository('AppBundle:Job')->findOneByTitle($jobText); if (null === $job) { $job = new Job(); $job->setTitle($jobText); } return $job; }
/** * @Route("/job/{id}/notes", name="job_show_notes") * @Method("GET") */ public function getNotesAction(Job $job) { // To remember: "git grep job_show_notes" // END. To remember $notes = []; foreach ($job->getNotes() as $note) { $notes[] = ['id' => $note->getId(), 'username' => $note->getUsername(), 'avatarUri' => '/images/' . $note->getUserAvatarFilename(), 'note' => $note->getNote(), 'date' => $note->getCreatedAt()->format("Y-m-d")]; } $data = ['notes' => $notes]; return new JsonResponse($data); }
/** * @Route("/createjob", name="createjob") */ public function createJobAction() { $location = $this->getDoctrine()->getRepository('AppBundle:Location')->find(9700); $job = new Job(); $job->setNamejob('Eerste job buiten'); $job->setAdres('watermolenstraat 89'); $job->setCodpost($location); $em = $this->getDoctrine()->getManager(); $em->persist($job); $em->flush(); return new Response('Created job id: ' . $job->getId()); }
/** * @param Job $job * * @return Model; */ public function entityToModel(Job $job) { $model = new Model(); $model->setId($job->getId())->setCode($job->getCode())->setTitle($job->getTitle())->setActive($job->isActive()); if ($this->isModeFull()) { $model->setStartTime($job->getStartTime())->setEndTime($job->getEndTime())->setDuration($job->getDuration()); } return $model; }
protected function startConsole(Job $job) { /** @var EntityManager $em */ $em = $this->getDoctrine()->getManager(); $job->setUser($this->getUser()->getUsername()); $job->setDone(false); $job->setProgress(0); $job->setStatus("Job intialized"); $em->persist($job); $em->flush(); return $this->redirectToRoute('job.status', ['job' => $job->getId()]); }
/** * {@inheritDoc} */ public function doOtherStuffOnPrePersist() { $this->__initializer__ && $this->__initializer__->__invoke($this, 'doOtherStuffOnPrePersist', array()); return parent::doOtherStuffOnPrePersist(); }
/** * {@inheritDoc} */ public function getCategory() { $this->__initializer__ && $this->__initializer__->__invoke($this, 'getCategory', array()); return parent::getCategory(); }
/** * @Route("/job/status/{job}", name="job.status")) */ public function jobStatusAction(Job $job, Request $request) { $theme = new Theme(); $converter = new AnsiToHtmlConverter($theme); return $this->render('job/status.html.twig', ['job' => $job, 'output' => $converter->convert($job->getOutput())]); }
function preProcessing($id, $jobTemp = null) { if ($jobTemp == null) { $job = new Job(); $job->setIdNorm($id); $job->setIdType(1); $job->setIdUser($this->getUser()->getId()); $job->setDateReceipt(date_create(date('Y-m-d', time()))); $job->setDateImplement(date_create(date('Y-m-d', time()))); return $job; } else { $job = new Job(); $job->setIdUser($this->getUser()->getId()); $job->setIdNorm($jobTemp->getIdNorm()); $job->setDeclarant($jobTemp->getDeclarant()); $job->setDescription($jobTemp->getDescription()); $job->setFormula($jobTemp->getFormula()); $job->setIdType($jobTemp->getIdType()); $job->setQuantity($jobTemp->getQuantity()); $job->setRemark($jobTemp->getRemark()); $job->setSumma($jobTemp->getSumma()); $job->setValue($jobTemp->getValue()); $job->setDateReceipt(date_create(date('Y-m-d', time()))); $job->setDateImplement(date_create(date('Y-m-d', time()))); return $job; } }
/** * Creates a form to delete a Job entity. * * @param Job $job The Job entity * * @return \Symfony\Component\Form\Form The form */ private function createDeleteForm(Job $job) { return $this->createFormBuilder()->setAction($this->generateUrl('job_delete', array('id' => $job->getId())))->setMethod('DELETE')->getForm(); }
/** * @Route("/import/forum") */ function forumAction(Request $request) { $em = $this->getDoctrine()->getManager(); $form = $this->createFormBuilder()->add('fileName', 'text', array('label' => 'fileName'))->add('listNumber', 'text', array('label' => 'listNumber'))->add('idUser', 'text', array('label' => 'idUser'))->add('Save', 'submit', array('label' => 'Отправить'))->getForm(); $form->handleRequest($request); if ($form->isValid()) { $fileName = $request->request->all()['form']['fileName']; $listNumber = $request->request->all()['form']['listNumber']; $idUser = $request->request->all()['form']['idUser']; $xls = $this->get('phpexcel')->createPHPExcelObject($fileName); $xls->setActiveSheetIndex($listNumber); $sheet = $xls->getActiveSheet(); $arrImport = array(); //Массив работ $rowEnd = $sheet->getHighestRow(); for ($row = 2; $row <= $rowEnd; $row++) { $description = $sheet->getCellByColumnAndRow(1, $row)->getValue(); $zayavka = $sheet->getCellByColumnAndRow(2, $row)->getValue(); $podrazdelenie = $sheet->getCellByColumnAndRow(3, $row)->getValue(); $declarant = $sheet->getCellByColumnAndRow(4, $row)->getValue(); $date = new \DateTime(); $dateReceipt = $date->setTimestamp($this->excel_to_timestamp($sheet->getCellByColumnAndRow(5, $row))); $date1 = new \DateTime(); $dateImplement = $date1->setTimestamp($this->excel_to_timestamp($sheet->getCellByColumnAndRow(6, $row))); $preSize = $sheet->getCellByColumnAndRow(7, $row)->getValue(); $formula = $sheet->getCellByColumnAndRow(8, $row)->getValue(); $remark = $sheet->getCellByColumnAndRow(9, $row)->getValue(); if ($declarant == '' or $description == '' or $dateReceipt == '' or $dateImplement == '' or $formula == '') { } else { $job = new Job(); $norm = $em->getRepository('AppBundle:Norm')->find(229); $job->setIdNorm(229); $job->setIdType(2); $job->setIdUser($idUser); $job->setNorm($norm); $job->setQuantity(1); $job->setValue(0); $job->setSumma(0); $job->setDescription($description); //Описание материала $job->setDeclarant($declarant); //Сотрудник $job->setDateReceipt($dateReceipt); //Дата получения $job->setDateImplement($dateImplement); //Дата выполнения $job->setFormula($formula); //Формула $remark = array('remark' => $remark, 'zayavka' => $zayavka, 'podrazdelenie' => $podrazdelenie, 'preSize' => $preSize); $job->setRemark(serialize($remark)); $arrImport[] = $job; } } foreach ($arrImport as $job) { $em->persist($job); } $em->flush(); return $this->redirectToRoute('homepage'); } return $this->render('form/form.html.twig', array('form' => $form->createView())); }
/** * @param Job $job * * @return bool */ private function isJobDeletable(Job $job) { return $this->isGranted('ROLE_CALD_JOBS_DEL') && !count($job->getJobCalendars()) && !count($job->getNurseries()); }