/**
  * @param Request $request
  * @param string $filename
  *
  * @return string
  *
  * @Route("/categorize/{filename}", name="fileCategorize")
  */
 public function indexAction(Request $request, $filename)
 {
     $formModel = new UpdateMetaFormModel();
     $formModel->setNote(pathinfo($filename)['filename']);
     $form = $this->createForm(new UpdateMetaFormType(), $formModel);
     if ($request->getMethod() == 'POST') {
         $form->handleRequest($request);
         $docInfo = DocumentInfo::create('', $formModel);
         /** @var DocumentService $docService */
         $docService = $this->get(DocumentService::SERVICE_NAME);
         $docService->processDocument($filename, $docInfo);
         return $this->redirect($this->generateUrl('listIncoming'));
     }
     return $this->render('categorize/index.html.twig', array('form' => $form->createView(), 'filename' => $filename));
 }
Пример #2
0
 /**
  * @param $filename
  * @param DocumentInfo $docInfo
  */
 public function processDocument($filename, DocumentInfo $docInfo)
 {
     $newFilename = $docInfo->createNewFilename();
     if ($docInfo->getPaymentStatus() == PaymentStatus::TO_PAY) {
         $this->moveDocument($this->getIncomingFolder() . '/' . $filename, $this->getToPayFolder() . '/' . $newFilename);
     } else {
         if ($docInfo->getCategory() == Category::PERSONAL) {
             $this->moveDocument($this->getIncomingFolder() . '/' . $filename, $this->getArchivePersonalFolder() . '/' . $newFilename);
         } elseif ($docInfo->getCategory() == Category::DRC) {
             $this->moveDocument($this->getIncomingFolder() . '/' . $filename, $this->getArchiveDRCFolder() . '/' . $newFilename);
         } elseif ($docInfo->getCategory() == Category::THV) {
             $this->moveDocument($this->getIncomingFolder() . '/' . $filename, $this->getArchiveTHVFolder() . '/' . $newFilename);
         } else {
             $this->moveDocument($this->getIncomingFolder() . '/' . $filename, $this->getArchiveUnknownFolder() . '/' . $newFilename);
         }
     }
 }
Пример #3
0
 public static function create($origFilename, UpdateMetaFormModel $formModel)
 {
     $docInfo = new DocumentInfo();
     $docInfo->setOrigFilename($origFilename)->setCategory($formModel->getCategory())->setDocDate($formModel->getDocDate())->setScanningNumber($formModel->getScanningNumber())->setPaymentStatus($formModel->getPaymentStatus())->setNote($formModel->getNote());
     return $docInfo;
 }