src/Service/Finance/LeadService.php line 46

Open in your IDE?
  1. <?php
  2. namespace App\Service\Finance;
  3. use Symfony\Contracts\Translation\TranslatorInterface;
  4. use App\Service\Kernel\KernelService;
  5. use DateTime;
  6. use Doctrine\ORM\EntityManagerInterface;
  7. use App\Entity\Finance\Lead;
  8. use App\Entity\CMS\CMSVacancy;
  9. use App\Service\Kernel\DMSService;
  10. use App\Entity\Finance\SalesCondition;
  11. /**
  12.  * Description of LeadService
  13.  *
  14.  * @author SebastiaanVanHerbrug
  15.  */
  16. // WERKT NIET 
  17. class LeadService {
  18.         private $TranslatorInterface;
  19.         private $entityManager;
  20.         private $kernel_service;
  21.         private $dMSService;
  22.         
  23.     public function __construct(TranslatorInterface $translator,  EntityManagerInterface $entityManager,
  24.         KernelService $kernel_service,
  25.         DMSService $dMSService) {
  26.         $this->TranslatorInterface = $translator;
  27.         $this->entityManager = $entityManager;
  28.         $this->kernel_service = $kernel_service;
  29.         $this->dMSService = $dMSService;
  30.     }
  31.    
  32.     public function checkBetween0and100(float $chance, TranslatorInterface $translator){
  33.         if($chance > 1 || $chance<0){
  34.             $this->TranslatorInterface->get('session')->getFlashBag()->add('error', $translator->trans('Lead.valuemustbebetween0and100'));
  35.             return false;
  36.         }else{
  37.             return true;
  38.         }
  39.     }
  40.     
  41.     public function createLead($subject, $details, $client, $endClient, $function, $technology, $language, $chance, $open, $owner, $externalId=null, $created = null, $organization)
  42.     {
  43.         $entityManager = $this->entityManager;
  44.         $dmsservice = $this->dMSService;
  45.         //$date = new DateTime($dateString);
  46.         
  47.         $lead = new Lead();
  48.         $lead->setOrganization($organization);
  49.         $lead->setSubject($subject);
  50.         $lead->setDetails($details);
  51.         $lead->setClient($client);
  52.         $lead->setEndClient($endClient);
  53.         //Opzoeken
  54.         $lead->setFunction($function);
  55.         $lead->setTechnology($technology);
  56.         
  57.         $lead->setLanguage($language);
  58.         $lead->setChance($chance);
  59.         $lead->setOwner($owner);
  60.         $lead->setExternalid($externalId);
  61.         $lead->setState(0);
  62.         $lead->setOpen($open);
  63.         
  64.         $typeListItem = $this->kernel_service->getListItem("Finance.LeadType", "LeadType.Resource", $organization);
  65.         $lead->setType($typeListItem);
  66.         
  67.         
  68.         
  69.         
  70.         
  71.         if ($created != null)
  72.         {
  73.             $lead->setCreated($created);
  74.             $entityManager->persist($lead);
  75.             $entityManager->flush();
  76.         }
  77.         /*
  78.         $cmsvacancy = new CMSVacancy();
  79.         $cmsvacancy->setLead($lead);
  80.         $cmsvacancy->setWebsite($website);
  81.         $cmsvacancy->setSubject($subject);
  82.         $cmsvacancy->setLocation($location);
  83.         $cmsvacancy->setDetails($details);
  84.          * 
  85.          */
  86.         
  87.         return $lead;
  88.         /*$invoice->setClient($entityManager->getRepository(Client::class)->findOneById($clientid));
  89.         $invoice->setAbout($about);
  90.         $invoice->setNote($note);
  91.         $invoice->setInvoiceDate($date);
  92.         $invoice->setOrganization($organization);
  93.         if (!$invoiceNumber) {
  94.             $invoiceNumber = $this->nextInvoiceNumber($date, $organization);
  95.         }
  96.         $invoice->setInvoiceNumber($invoiceNumber);
  97.         // Currency auto
  98.         $invoice->setCurrency($this->kernel_service->getApplicationInfoValue('Kernel.DefaultCurrency'));
  99.         $invoice->setLanguage($language);
  100.         $salesCondition = $entityManager->getRepository(SalesCondition::class)->findOneById($salesConditionId);
  101.         $invoice->setSalesCondition($salesCondition);
  102.         $invoice->setSalesConditionText($salesCondition->getTranslatedDescription($language));
  103.         $invoice->setState(0);
  104.         
  105.         $this->copyFieldsFromClientToInvoice($invoice);
  106.         if ($this->checkForDuplicates($invoice)) {
  107.             $entityManager->persist($invoice);
  108.             $entityManager->flush();
  109.             if ($createPDF == true)
  110.             {
  111.                 $this->updatePDF($invoice);
  112.             }
  113.             $this->createFolderIfNeeded($invoice);
  114.             return $invoice;
  115.         } else {
  116.             return -1;
  117.         }*/
  118.     }
  119.  
  120. }