Esempio n. 1
0
 public function init()
 {
     $this->serviceLocator = $this->getFormFactory()->getFormElementManager()->getServiceLocator();
     $hydrator = new DoctrineHydrator($this->getObjectManager(), 'Lead\\Entity\\Lead');
     $hydrator->addStrategy('timecreated', new DateTimeStrategy());
     $this->setAttribute('method', 'post')->setHydrator($hydrator);
     $dateTime = date('Y-m-d H:i:s');
     $this->add(array('options' => array('label' => 'IP Address'), 'required' => false, 'type' => 'text', 'name' => 'ipaddress'));
     $this->add(array('options' => array('label' => 'Referrer'), 'required' => false, 'type' => 'Zend\\Form\\Element\\Url', 'name' => 'referrer'));
     $this->add(array('name' => 'account', 'type' => 'DoctrineModule\\Form\\Element\\ObjectSelect', 'required' => false, 'allow_empty' => true, 'continue_if_empty' => true, 'options' => array('label' => 'Account', 'empty_option' => 'None', 'object_manager' => $this->getObjectManager(), 'target_class' => 'Account\\Entity\\Account', 'property' => 'name', 'find_method' => array('name' => 'findBy', 'params' => array('criteria' => array('active' => 1)))), 'attributes' => array('id' => 'account')));
     $this->add(array('type' => 'Application\\Form\\Element\\Collection', 'name' => 'attributes', 'required' => true, 'options' => array('label' => 'Add Lead Details', 'count' => 8, 'should_create_template' => true, 'template_placeholder' => '__index__', 'allow_add' => true, 'allow_remove' => true, 'target_element' => array('type' => 'Lead\\Form\\Fieldset\\LeadAttributeValueFieldset')), 'attributes' => array('id' => 'leadAttributes')));
     $this->add(array('type' => 'Zend\\Form\\Element\\Csrf', 'name' => 'csrf'));
     $this->add(array('name' => 'submit', 'type' => 'Zend\\Form\\Element\\Submit', 'attributes' => array('type' => 'submit', 'value' => 'Add Lead', 'id' => 'submit', 'class' => 'btn btn-primary')));
     $this->add(array('name' => 'cancel', 'type' => 'button', 'class' => 'btn btn-default', 'options' => array('label' => 'Cancel', 'label_attributes' => array('sr-only')), 'attributes' => array('value' => 'Cancel', 'class' => 'btn btn-default')));
 }
 public function init()
 {
     $hydrator = new DoctrineHydrator($this->getObjectManager(), 'Agent\\Entity\\AgentCriterionValue');
     $hydrator->addStrategy('value', new AgentCriterionValueStrategy());
     $this->setHydrator($hydrator)->setObject(new AgentCriterionValue());
     $this->add(array('type' => 'Zend\\Form\\Element\\Hidden', 'name' => 'id', 'required' => false));
     $this->add(array('type' => 'Zend\\Form\\Element\\Hidden', 'name' => 'type', 'required' => true, 'attributes' => array('class' => 'type')));
     $this->add(array('type' => 'Zend\\Form\\Element\\Hidden', 'name' => 'value', 'required' => false, 'attributes' => array('class' => 'value')));
     $this->add(array('options' => array('label' => 'Enter Value:', 'label_attributes' => array('class' => '')), 'attributes' => array('class' => 'criterion string', 'placeholder' => 'Enter Value'), 'type' => 'text', 'name' => 'string'));
     $this->add(array('options' => array('label' => 'Choose Value(s): ', 'label_attributes' => array('class' => 'sr-only'), 'empty_option' => 'Select Value(s)', 'value_options' => array()), 'attributes' => array('class' => 'criterion multiple', 'multiple' => 'multiple'), 'type' => 'select', 'name' => 'multiple'));
     $this->add(array('options' => array('label' => 'Select a Boolean Value: ', 'label_attributes' => array('class' => 'horizontal'), 'value_options' => array(0 => 'No', 1 => 'Yes')), 'attributes' => array('class' => 'criterion boolean horizontal', 'style' => 'width: 100px'), 'type' => 'select', 'name' => 'boolean'));
     $this->add(array('name' => 'daterange', 'allow_empty' => true, 'filters' => array(array('name' => 'Zend\\Filter\\StringTrim')), 'type' => 'Application\\Form\\Element\\DateRange', 'options' => array('column-size' => 'xs-12 col-sm-6 col-md-4', 'label' => 'Select Date Range: ', 'label_attributes' => array('class' => '')), 'attributes' => array('class' => 'criterion daterange', 'id' => 'daterange_' . uniqid())));
     $this->add(array('name' => 'location', 'type' => 'Agent\\Form\\Fieldset\\LocationFieldset', 'use_as_base_fieldset' => false, 'attributes' => array('class' => 'criterion location group-fieldset', 'id' => 'location_' . uniqid())));
     $this->add(array('type' => 'Application\\Form\\Element\\Slider', 'name' => 'range', 'options' => array('label' => 'Select Range: ', 'label_attributes' => array('class' => 'horizontal')), 'attributes' => array('data-slider-min' => 0, 'data-slider-max' => 100, 'data-slider-step' => 1, 'data-slider-range' => true, 'data-slider-tick' => '[0, 25, 50, 75, 100]', 'data-slider-ticks_labels' => '["0", "25", "50", "75", "100"]', 'data-slider-handle' => 'square', 'class' => 'criterion range slider horizontal', 'id' => 'slider_' . uniqid())));
 }
Esempio n. 3
0
 public function init()
 {
     $this->serviceLocator = $this->getFormFactory()->getFormElementManager()->getServiceLocator();
     $hydrator = new DoctrineHydrator($this->getObjectManager(), 'Report\\Entity\\Report');
     $hydrator->addStrategy('updated', new DateTimeStrategy());
     $this->setAttribute('method', 'post')->setHydrator($hydrator)->setInputFilter(new AddFormInputFilter($this->getServiceLocator()));
     $dateTime = date('Y-m-d H:i:s');
     $this->add(array('required' => false, 'type' => 'Zend\\Form\\Element\\Hidden', 'name' => 'id'));
     $this->add(array('required' => false, 'type' => 'Zend\\Form\\Element\\Hidden', 'name' => 'active'));
     $this->add(array('required' => true, 'type' => 'Zend\\Form\\Element\\Hidden', 'name' => 'updated', 'attributes' => array('value' => $dateTime)));
     $this->add(array('required' => true, 'type' => 'Zend\\Form\\Element\\Hidden', 'name' => 'name', 'attributes' => array('value' => "Search ({$dateTime})")));
     $this->add(array('required' => true, 'type' => 'Zend\\Form\\Element\\Hidden', 'name' => 'account', 'attributes' => array('id' => 'account')));
     $this->add(array('name' => 'agent', 'type' => 'Agent\\Form\\Fieldset\\AgentFieldset', 'options' => array('label' => "Advanced Search", 'use_as_base_fieldset' => false), 'attributes' => array('id' => 'agent', 'class' => 'collection-fieldset')));
     $this->add(array('name' => 'submit', 'type' => 'Zend\\Form\\Element\\Submit', 'attributes' => array('type' => 'submit', 'value' => 'Search', 'id' => 'submit', 'class' => 'btn btn-primary')));
     $this->add(array('name' => 'cancel', 'type' => 'button', 'class' => 'btn btn-default', 'options' => array('label' => 'Cancel', 'label_attributes' => array('sr-only')), 'attributes' => array('value' => 'Cancel', 'class' => 'btn btn-default')));
 }
Esempio n. 4
0
 public function init()
 {
     $this->serviceLocator = $this->getFormFactory()->getFormElementManager()->getServiceLocator();
     $hydrator = new DoctrineHydrator($this->getObjectManager(), 'Report\\Entity\\Report');
     $hydrator->addStrategy('updated', new DateTimeStrategy());
     $this->setAttribute('method', 'post')->setHydrator($hydrator)->setInputFilter(new AddFormInputFilter($this->getServiceLocator()));
     $dateTime = date('Y-m-d H:i:s');
     $this->add(array('required' => false, 'type' => 'Zend\\Form\\Element\\Hidden', 'name' => 'id'));
     $this->add(array('required' => true, 'type' => 'Zend\\Form\\Element\\Hidden', 'name' => 'updated'));
     $this->add(array('required' => true, 'type' => 'Zend\\Form\\Element\\Hidden', 'name' => 'active'));
     $this->add(array('options' => array('label' => 'Name'), 'attributes' => array('value' => "Report ({$dateTime})"), 'required' => true, 'type' => 'text', 'name' => 'name'));
     $this->add(array('name' => 'account', 'type' => 'DoctrineModule\\Form\\Element\\ObjectSelect', 'required' => false, 'allow_empty' => true, 'continue_if_empty' => true, 'options' => array('label' => 'Client Account', 'empty_option' => 'None', 'object_manager' => $this->getObjectManager(), 'target_class' => 'Account\\Entity\\Account', 'property' => 'name', 'find_method' => array('name' => 'findBy', 'params' => array('criteria' => array('active' => 1)))), 'attributes' => array('id' => 'account')));
     $this->add(array('name' => 'agent', 'type' => 'Agent\\Form\\Fieldset\\AgentFieldset', 'options' => array('label' => "Setup Search Agent", 'use_as_base_fieldset' => false), 'attributes' => array('id' => 'agent', 'class' => 'collection-fieldset')));
     $this->add(array('name' => 'submit', 'type' => 'Zend\\Form\\Element\\Submit', 'attributes' => array('type' => 'submit', 'value' => 'Create Report', 'id' => 'submit', 'class' => 'btn btn-primary')));
     $this->add(array('name' => 'cancel', 'type' => 'button', 'class' => 'btn btn-default', 'options' => array('label' => 'Cancel', 'label_attributes' => array('sr-only')), 'attributes' => array('value' => 'Cancel', 'class' => 'btn btn-default')));
 }
 public function addManualEntry()
 {
     $objectManager = $this->getEntityManager();
     $hydrator = new DoctrineHydrator($this->getEntityManager());
     $blogPost = new ChildParent();
     $tags = array();
     $tag1 = new Children();
     $tag1->setName('PHP');
     $tags[] = $tag1;
     $tag2 = new Children();
     $tag2->setName('STL');
     $tags[] = $tag2;
     $data = array('name' => 'The best blog post in the world !', 'tags' => $tags);
     $blogPost = $hydrator->hydrate($data, $blogPost);
     $objectManager->persist($blogPost);
     $objectManager->flush();
 }
 public function getForm($entityClass = null)
 {
     $form = parent::getForm($entityClass);
     if ($form) {
         $entityClass = $entityClass ?: $this->getEntityClass();
         $hydrator = new DoctrineHydrator($this->getEntityManager(), $entityClass);
         $hydrator->addStrategy('timecreated', new DateTimeStrategy());
         $hydrator->addStrategy('lastsubmitted', new DateTimeStrategy());
         $form->setHydrator($hydrator);
         if ($form->has('submit')) {
             $form->get('submit')->setLabel('Save');
         }
         if ($form->has('cancelar')) {
             $form->get('cancelar')->setLabel('Cancel')->setName('cancel');
         }
     }
     return $form;
 }
 public function extractLead(Lead $lead)
 {
     $headings = $this->exportHeadings;
     $entityManager = $this->getEntityManager();
     $hydrator = new DoctrineHydrator($entityManager);
     $leadArray = $hydrator->extract($lead);
     $output = array_combine($headings, array_pad([], count($headings), ""));
     foreach ($headings as $heading) {
         switch ($heading) {
             case "Account":
                 $account = $lead->getAccount();
                 $output[$heading] = $account ? $account->getName() : "N/A";
                 break;
             case "Time Created":
                 $time = $lead->getTimecreated();
                 if ($time instanceof \DateTime) {
                     $time = date_format($time, 'Y-m-d H:i:s');
                 }
                 $output[$heading] = $time;
                 break;
             case "Referrer":
                 $output[$heading] = $lead->getReferrer();
                 break;
             case "IP Address":
                 $output[$heading] = $lead->getIpaddress();
                 break;
             default:
                 $attribute = $lead->findAttribute($heading);
                 if (!$attribute) {
                     $attributes = $lead->getAttributes(true)->filter(function ($attribute) use($heading) {
                         $real_attribute = false;
                         $attribute_desc = false;
                         if ($attribute) {
                             $real_attribute = $attribute->getAttribute();
                         }
                         if ($real_attribute) {
                             $attribute_desc = $real_attribute->getAttributeDesc();
                         }
                         return $attribute_desc == $heading;
                     });
                     if ($attributes->count() > 0) {
                         $attribute = $attributes->first();
                     }
                 }
                 if ($attribute) {
                     $output[$heading] = $attribute->getValue();
                 }
                 break;
         }
     }
     return $output;
 }
 protected function getLead($id, $extract = true)
 {
     $em = $this->getEntityManager();
     $lead = $this->lead;
     if (!$lead || $lead instanceof Lead && $lead->getId() != $id) {
         $leadRepository = $em->getRepository("Lead\\Entity\\Lead");
         $lead = $leadRepository->findOneBy(['id' => $id]);
         $this->setLead($lead);
     }
     if ($lead) {
         if ($extract) {
             $hydrator = new DoctrineHydrator($em);
             return $hydrator->extract($lead);
         }
         return $lead;
     }
     return false;
 }
 protected function extract(Lead $lead)
 {
     $entityClass = get_class($lead);
     $hydrator = new DoctrineHydrator($this->getEntityManager(), $entityClass);
     $hydrator->addStrategy('timecreated', new DateTimeStrategy());
     $hydrator->addStrategy('lastsubmitted', new DateTimeStrategy());
     return $hydrator->extract($lead);
 }
Esempio n. 10
0
 public function exportAction()
 {
     set_time_limit(0);
     $results = array();
     $labels = array();
     $headings = array();
     $limit = $this->getLimit($this->defaultPageSize);
     $page = $this->getRequest()->getQuery('page', 0);
     $sort = $this->getRequest()->getQuery('sort', $this->defaultSort);
     $order = $this->getRequest()->getQuery('order', $this->defaultOrder);
     if (empty($sort)) {
         $sort = $this->defaultSort;
     }
     /* @var $qb \Doctrine\ORM\QueryBuilder */
     $qb = $this->getEntityManager()->createQueryBuilder();
     $qb->add('select', 'e')->add('from', $this->getEntityClass() . ' e')->orderBy('e.' . $sort, $order);
     $qb = $this->handleSearch($qb);
     $entityManager = $this->getEntityManager();
     $hydrator = new DoctrineHydrator($entityManager);
     $eventPrototype = new Event();
     $eventArray = $hydrator->extract($eventPrototype);
     $eventArray = array_map('ucwords', array_keys($eventArray));
     $leadArray = ['id', 'Full Name', 'Account'];
     $leadArray = array_map('ucwords', $leadArray);
     $headings = ['event' => $eventArray, 'lead' => $leadArray];
     foreach ($headings as $entity => $array) {
         foreach ($array as $heading) {
             $mergedArray[] = ucwords($entity . ' ' . $heading);
         }
     }
     $this->exportHeadings = $mergedArray;
     $results = $qb->getQuery()->getResult();
     return $this->csvExport('Event Log (' . date('Y-m-d') . ').csv', $this->exportHeadings, $results, array($this, 'extractEvent'));
 }
Esempio n. 11
0
 public function update($id, $data)
 {
     $this->createServiceEvent()->setEntityId($id)->setEntityClass($this->getEntityClass())->setDescription("Lead Edited");
     $em = $this->getEntityManager();
     $leadRepository = $em->getRepository("Lead\\Entity\\Lead");
     $entity = $leadRepository->findOneBy(['id' => $id]);
     $hydrator = new DoctrineHydrator($em);
     try {
         $lead = $hydrator->hydrate($data, $entity);
         $em->persist($lead);
         $em->flush();
     } catch (\Exception $e) {
         $this->logError($e);
         return $this->getJsonErrorResponse('json')->errorHandler(400, "Invalid Submission. " . $e->getMessage(), $data);
     }
     if ($lead) {
         $this->getServiceEvent()->setEntityId($lead->getId())->setMessage("Lead #" . $lead->getId() . " edited.");
         $this->logEvent("EditAction.post");
     }
     return $lead;
 }
 /**
  *
  * @param string $action        	
  * @param string $message        	
  * @return \Event\Entity\Event
  */
 protected function getEvent($action = null, $message = null)
 {
     if (!$this->event) {
         if (!$action) {
             $action = 'Unknown ' . get_called_class() . ' Event';
         }
         if (!$message) {
             $message = 'Unknown ' . get_called_class() . ' Event';
         }
         $data = ['event' => $action, 'occurred' => new \DateTime('now'), 'message' => $message];
         try {
             $event = new Event();
             $hydrator = new DoctrineHydrator($this->getEntityManager(), get_class($event));
             $event = $hydrator->hydrate($data, $event);
             $entityManager = $this->getEntityManager();
             $entityManager->persist($event);
             $entityManager->flush();
             $this->event = $event;
         } catch (\Exception $e) {
             // fail silently
             return false;
         }
     }
     return $this->event;
 }