/** * @see Command */ protected function execute(InputInterface $input, OutputInterface $output) { $em = $this->getContainer()->get('doctrine.orm.entity_manager'); $repository = $em->getRepository('WealthbotClientBundle:Workflow'); $workflow = $repository->findAll(); $count = 0; foreach ($workflow as $workflowItem) { $type = $workflowItem->getType(); if ($type === Workflow::TYPE_PAPERWORK) { $messageCodes = array_flip(Workflow::getPaperworkMessageChoices()); } else { $messageCodes = array_flip(Workflow::getAlertMessageChoices()); } $workflowItem->setMessageCode($messageCodes[$workflowItem->getDbMessage()]); $em->persist($workflowItem); $count++; } $em->flush(); $output->writeln(sprintf('Updated %d items.', $count)); }
public function PostFlush(PostFlushEventArgs $eventArgs) { $activityManager = $this->container->get('wealthbot.activity.manager'); $paperworkMessages = Workflow::getPaperworkMessageChoices(); foreach ($this->inserted as $entity) { if ($entity instanceof ActivityInterface) { $activityManager->saveActivityByObject($entity); } if ($entity instanceof Distribution || $entity instanceof BaseContribution) { $client = $entity->getClientAccount()->getClient(); $message = str_replace('New/Update', 'New', $paperworkMessages[$entity->getWorkflowMessageCode()]); $message = substr($message, 0, -1); $activity = $this->createActivity($client, $message, $entity->getAmount()); $activityManager->updateActivity($activity); } } }
/** * Create new workflow * * @param User $client * @param WorkflowableInterface $object * @param integer $type * @param DocumentSignature|DocumentSignature[] $signatures * @param array $objectIds * @return Workflow|null * @throws \InvalidArgumentException */ public function createWorkflow(User $client, WorkflowableInterface $object, $type, $signatures = null, array $objectIds = null) { $class = $this->om->getClassMetadata(get_class($object))->getName(); $workflow = new Workflow(); $workflow->setClient($client); $workflow->setType($type); $workflow->setObjectType($class); $workflow->setMessageCode($object->getWorkflowMessageCode()); if (method_exists($object, 'getId') && null !== $object->getId()) { $workflow->setObjectId($object->getId()); } if ($type == Workflow::TYPE_PAPERWORK) { $documentSignatures = array(); if (null === $signatures && $object instanceof SignableInterface) { $signature = $this->signatureManager->findDocumentSignatureBySource($object); if ($signature) { $documentSignatures[] = $signature; } } else { if (is_object($signatures)) { if (!$signatures instanceof DocumentSignature) { throw new \InvalidArgumentException('Parameter signatures must be array or instance of DocumentSignature.'); } $documentSignatures[] = $signatures; } elseif (is_array($signatures)) { $documentSignatures = $signatures; } } if (count($documentSignatures)) { foreach ($documentSignatures as $documentSignature) { $workflow->addDocumentSignature($documentSignature); } $this->updateClientStatusByDocumentSignatures($workflow); } if ($object instanceof ClientPortfolio) { $this->updateClientStatusByClientPortfolio($workflow, $object); } } elseif ($object instanceof SystemAccount) { $this->updateClientStatusBySystemAccount($workflow, $object); } if (null !== $objectIds) { $workflow->setObjectIds($objectIds); } if ($object instanceof PaymentWorkflowableInterface) { $workflow->setAmount($object->getWorkflowAmount()); } $this->om->persist($workflow); $this->om->flush(); return $workflow; }
public function sendCustodianWorkflowDocuments(User $ria, Workflow $workflow) { $documents = array(); if ($workflow->canHaveDocuments()) { /** @var DocumentSignature $signature */ foreach ($workflow->getDocumentSignatures() as $signature) { $document = $signature->getDocument(); $documents[$document->getOriginalName()] = $this->router->generate('rx_download_document', array('filename' => $document->getFilename(), 'originalName' => $document->getOriginalName()), true); } } if (count($documents)) { $template = $this->parameters['template']['docusign_custodian_workflow_documents']; $fromEmail = $this->parameters['from_email']['docusign_custodian_workflow_documents']; $custodian = $ria->getCustodian(); $context = array('custodian' => $custodian, 'ria' => $ria, 'logo' => $this->getRiaLogo($ria->getId())); return $this->sendMessage($template, $fromEmail, $custodian->getEmail(), $context, $documents); } return 0; }