From bb709cadd210d868110a5367536a1b74b73ca158 Mon Sep 17 00:00:00 2001 From: Zdeno Kuzmany Date: Wed, 7 Feb 2018 00:19:03 +0100 Subject: [PATCH 01/17] Show in contacts tab option in form --- app/bundles/FormBundle/Entity/Form.php | 27 ++++++++++ app/bundles/FormBundle/Form/Type/FormType.php | 7 +++ .../Translations/en_US/messages.ini | 2 + .../FormBundle/Views/Builder/index.html.php | 1 + app/migrations/Version20180206225101.php | 53 +++++++++++++++++++ 5 files changed, 90 insertions(+) create mode 100644 app/migrations/Version20180206225101.php diff --git a/app/bundles/FormBundle/Entity/Form.php b/app/bundles/FormBundle/Entity/Form.php index 8f914be0404..862a8ddd25d 100644 --- a/app/bundles/FormBundle/Entity/Form.php +++ b/app/bundles/FormBundle/Entity/Form.php @@ -100,6 +100,11 @@ class Form extends FormEntity */ private $renderStyle = false; + /** + * @var bool + */ + private $inContactTab = false; + /** * @ORM\OneToMany(targetEntity="Submission", mappedBy="form", fetch="EXTRA_LAZY") * @ORM\OrderBy({"dateSubmitted" = "DESC"}) @@ -204,6 +209,11 @@ public static function loadMetadata(ORM\ClassMetadata $metadata) ->nullable() ->build(); + $builder->createField('inContactTab', 'boolean') + ->columnName('in_contact_tab') + ->nullable() + ->build(); + $builder->createOneToMany('submissions', 'Submission') ->setOrderBy(['dateSubmitted' => 'DESC']) ->mappedBy('form') @@ -290,6 +300,7 @@ public static function loadApiMetadata(ApiMetadataDriver $metadata) 'actions', 'template', 'inKioskMode', + 'inContactTab', 'renderStyle', 'formType', 'postAction', @@ -735,6 +746,22 @@ public function setInKioskMode($inKioskMode) $this->inKioskMode = $inKioskMode; } + /** + * @return mixed + */ + public function getInContactTab() + { + return $this->inContactTab; + } + + /** + * @param mixed $inContactTab + */ + public function setInContactTab($inContactTab) + { + $this->inContactTab = $inContactTab; + } + /** * @param mixed $renderStyle */ diff --git a/app/bundles/FormBundle/Form/Type/FormType.php b/app/bundles/FormBundle/Form/Type/FormType.php index 3c3f2e9ff0e..68fb779a0f4 100644 --- a/app/bundles/FormBundle/Form/Type/FormType.php +++ b/app/bundles/FormBundle/Form/Type/FormType.php @@ -106,6 +106,13 @@ public function buildForm(FormBuilderInterface $builder, array $options) ], ]); + $builder->add('inContactTab', 'yesno_button_group', [ + 'label' => 'mautic.form.form.contacttab', + 'attr' => [ + 'tooltip' => 'mautic.form.form.contacttab.tooltip', + ], + ]); + // Render style for new form by default if ($options['data']->getId() === null) { $options['data']->setRenderStyle(true); diff --git a/app/bundles/FormBundle/Translations/en_US/messages.ini b/app/bundles/FormBundle/Translations/en_US/messages.ini index b94e9f8972b..db96ea23386 100644 --- a/app/bundles/FormBundle/Translations/en_US/messages.ini +++ b/app/bundles/FormBundle/Translations/en_US/messages.ini @@ -129,6 +129,8 @@ mautic.form.form.help.manualcopy.script="Copy and paste into the document's head mautic.form.form.help.searchcommands="Search commands
ids:ID1,ID2 (comma separated IDs, no spaces)
is:mine
is:published
is:unpublished
has:results
name:*
is:uncategorized
category:{category alias}" mautic.form.form.kioskmode="Kiosk Mode" mautic.form.form.kioskmode.tooltip="If set to yes, form submissions will not generate new contact tracking cookies or assign the IP address to created/updated contacts." +mautic.form.form.contacttab="Show results in contacts tab" +mautic.form.form.contacttab.tooltip="If set to yes, form results will show in contacts detail tab." mautic.form.form.renderstyle="Render Style" mautic.form.form.renderstyle.tooltip="Disable CSS rendering" mautic.form.form.modalheader="Form Component Details" diff --git a/app/bundles/FormBundle/Views/Builder/index.html.php b/app/bundles/FormBundle/Views/Builder/index.html.php index 81e84d402b7..f61d6ea089a 100644 --- a/app/bundles/FormBundle/Views/Builder/index.html.php +++ b/app/bundles/FormBundle/Views/Builder/index.html.php @@ -196,6 +196,7 @@ echo $view['form']->row($form['isPublished']); echo $view['form']->row($form['publishUp']); echo $view['form']->row($form['publishDown']); + echo $view['form']->row($form['inContactTab']); echo $view['form']->row($form['inKioskMode']); echo $view['form']->row($form['renderStyle']); echo $view['form']->row($form['template']); diff --git a/app/migrations/Version20180206225101.php b/app/migrations/Version20180206225101.php new file mode 100644 index 00000000000..2875ee4d3d8 --- /dev/null +++ b/app/migrations/Version20180206225101.php @@ -0,0 +1,53 @@ +getTable(MAUTIC_TABLE_PREFIX.'forms')->hasColumn('in_contact_tab')) { + throw new SkipMigrationException('Schema includes this migration'); + } + } + + /** + * @param Schema $schema + */ + public function up(Schema $schema) + { + $this->addSql('ALTER TABLE '.$this->prefix.'forms ADD COLUMN in_contact_tab bool DEFAULT NULL'); + } + + /** + * @param Schema $schema + */ + public function postUp(Schema $schema) + { + $q = $this->connection->createQueryBuilder(); + $q->update(MAUTIC_TABLE_PREFIX.'forms') + ->set('in_contact_tab', 0) + ->execute(); + } +} From 20c736939d00aa136cf47d55763baecb5d46fa9e Mon Sep 17 00:00:00 2001 From: Zdeno Kuzmany Date: Wed, 7 Feb 2018 01:23:33 +0100 Subject: [PATCH 02/17] Another work on form tab --- .../FormBundle/Entity/FormRepository.php | 25 +++++++++++++++++++ .../LeadBundle/Controller/LeadController.php | 1 + .../Translations/en_US/messages.ini | 1 + .../LeadBundle/Views/Form/list.html.php | 24 ++++++++++++++++++ .../LeadBundle/Views/Lead/lead.html.php | 22 ++++++++++++++++ app/migrations/Version20180206225101.php | 4 +-- 6 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 app/bundles/LeadBundle/Views/Form/list.html.php diff --git a/app/bundles/FormBundle/Entity/FormRepository.php b/app/bundles/FormBundle/Entity/FormRepository.php index 4a600c413ae..28838581139 100644 --- a/app/bundles/FormBundle/Entity/FormRepository.php +++ b/app/bundles/FormBundle/Entity/FormRepository.php @@ -197,6 +197,31 @@ public function getFormResults(Form $form, array $options = []) return $query->execute()->fetchAll(); } + /** + * Return Form entities and form results. + * + * @param null $leadId + * @param bool $inContactTab + * + * @return array + */ + public function getFormsWithResults($leadId = null, $inContactTab = false) + { + if ($inContactTab) { + $entities = $this->getEntities(['filter'=>['force'=>[0=>['column' => 'f.inContactTab', 'expr' => 'eq', 'value' => 1]]]]); + } else { + $entities = $this->getEntities(); + } + + $formResults = []; + foreach ($entities as $key=>$entity) { + $formResults[$key]['entity'] = $entity; + $formResults[$key]['results'] = $this->getFormResults($entity[0], ['leadId'=>$leadId]); + } + + return $formResults; + } + /** * Compile and return the form result table name. * diff --git a/app/bundles/LeadBundle/Controller/LeadController.php b/app/bundles/LeadBundle/Controller/LeadController.php index c927f1c46ca..3918cbd5d7c 100644 --- a/app/bundles/LeadBundle/Controller/LeadController.php +++ b/app/bundles/LeadBundle/Controller/LeadController.php @@ -370,6 +370,7 @@ public function viewAction($objectId) 'integrations' => $integrationRepo->getIntegrationEntityByLead($lead->getId()), 'auditlog' => $this->getAuditlogs($lead), 'doNotContact' => $emailRepo->checkDoNotEmail($fields['core']['email']['value']), + 'leadForms' => $this->getModel('form')->getRepository()->getFormsWithResults($lead->getId(), true), 'leadNotes' => $this->forward( 'MauticLeadBundle:Note:index', [ diff --git a/app/bundles/LeadBundle/Translations/en_US/messages.ini b/app/bundles/LeadBundle/Translations/en_US/messages.ini index fecf15da70e..db62d2aac38 100755 --- a/app/bundles/LeadBundle/Translations/en_US/messages.ini +++ b/app/bundles/LeadBundle/Translations/en_US/messages.ini @@ -329,6 +329,7 @@ mautic.lead.lead.tab.auditlog="Audit log" mautic.lead.lead.tab.socialactivity="Public Activity" mautic.lead.lead.tab.socialprofile="Public Profile" mautic.lead.lead.tab.places="Places" +mautic.lead.lead.tab.forms="Forms" mautic.lead.lead.thead.action="Triggering Action" mautic.lead.lead.thead.city="City" mautic.lead.lead.thead.country="Country" diff --git a/app/bundles/LeadBundle/Views/Form/list.html.php b/app/bundles/LeadBundle/Views/Form/list.html.php new file mode 100644 index 00000000000..aa50cb78699 --- /dev/null +++ b/app/bundles/LeadBundle/Views/Form/list.html.php @@ -0,0 +1,24 @@ + + +
+ + +
+ a +
+ + +
\ No newline at end of file diff --git a/app/bundles/LeadBundle/Views/Lead/lead.html.php b/app/bundles/LeadBundle/Views/Lead/lead.html.php index fcbe2293776..907fdd041d3 100644 --- a/app/bundles/LeadBundle/Views/Lead/lead.html.php +++ b/app/bundles/LeadBundle/Views/Lead/lead.html.php @@ -313,6 +313,17 @@ + + +
  • + + + + + trans('mautic.lead.lead.tab.forms'); ?> + +
  • + getCustomContent('tabs', $mauticTemplateVars); ?> @@ -391,6 +402,17 @@ + + +
    + render('MauticLeadBundle:Form:list.html.php', + [ + 'leadForms' => $leadForms, + ]); ?> +
    + + diff --git a/app/migrations/Version20180206225101.php b/app/migrations/Version20180206225101.php index 2875ee4d3d8..8ff274f8392 100644 --- a/app/migrations/Version20180206225101.php +++ b/app/migrations/Version20180206225101.php @@ -47,7 +47,7 @@ public function postUp(Schema $schema) { $q = $this->connection->createQueryBuilder(); $q->update(MAUTIC_TABLE_PREFIX.'forms') - ->set('in_contact_tab', 0) - ->execute(); + ->set('in_contact_tab', 0) + ->execute(); } } From c9960a243b0ab6d81f661347df5e1a09a9fe3974 Mon Sep 17 00:00:00 2001 From: Zdeno Kuzmany Date: Wed, 7 Feb 2018 01:24:26 +0100 Subject: [PATCH 03/17] Minor --- app/bundles/LeadBundle/Views/Form/list.html.php | 1 - 1 file changed, 1 deletion(-) diff --git a/app/bundles/LeadBundle/Views/Form/list.html.php b/app/bundles/LeadBundle/Views/Form/list.html.php index aa50cb78699..b4b40092f5a 100644 --- a/app/bundles/LeadBundle/Views/Form/list.html.php +++ b/app/bundles/LeadBundle/Views/Form/list.html.php @@ -14,7 +14,6 @@
    a From 67b87765f07e8edda8311895cd80ef68dee19685 Mon Sep 17 00:00:00 2001 From: Zdeno Kuzmany Date: Thu, 8 Feb 2018 01:38:42 +0100 Subject: [PATCH 04/17] Final --- .../FormBundle/Entity/FormRepository.php | 25 ------ .../FormBundle/Model/SubmissionModel.php | 71 +++++++++++++++++ .../Views/Result/list-condensed.html.php | 77 +++++++++++++++++++ .../LeadBundle/Controller/LeadController.php | 2 +- .../LeadBundle/Views/Form/list.html.php | 10 ++- 5 files changed, 155 insertions(+), 30 deletions(-) create mode 100644 app/bundles/FormBundle/Views/Result/list-condensed.html.php diff --git a/app/bundles/FormBundle/Entity/FormRepository.php b/app/bundles/FormBundle/Entity/FormRepository.php index 28838581139..4a600c413ae 100644 --- a/app/bundles/FormBundle/Entity/FormRepository.php +++ b/app/bundles/FormBundle/Entity/FormRepository.php @@ -197,31 +197,6 @@ public function getFormResults(Form $form, array $options = []) return $query->execute()->fetchAll(); } - /** - * Return Form entities and form results. - * - * @param null $leadId - * @param bool $inContactTab - * - * @return array - */ - public function getFormsWithResults($leadId = null, $inContactTab = false) - { - if ($inContactTab) { - $entities = $this->getEntities(['filter'=>['force'=>[0=>['column' => 'f.inContactTab', 'expr' => 'eq', 'value' => 1]]]]); - } else { - $entities = $this->getEntities(); - } - - $formResults = []; - foreach ($entities as $key=>$entity) { - $formResults[$key]['entity'] = $entity; - $formResults[$key]['results'] = $this->getFormResults($entity[0], ['leadId'=>$leadId]); - } - - return $formResults; - } - /** * Compile and return the form result table name. * diff --git a/app/bundles/FormBundle/Model/SubmissionModel.php b/app/bundles/FormBundle/Model/SubmissionModel.php index c7bd1d4e11c..9b2c7fc1470 100644 --- a/app/bundles/FormBundle/Model/SubmissionModel.php +++ b/app/bundles/FormBundle/Model/SubmissionModel.php @@ -1130,4 +1130,75 @@ protected function validateActionCallbacks(SubmissionEvent $event, &$validationE unset($args, $actions, $availableActions); } + + /** + * Return Forms with results to contacts tab + *ľ. + * + * @param null $leadId + * @param bool $inContactTab + * + * @return array + */ + public function getFormsWithResults($leadId = null, $inContactTab = false) + { + $formResults = []; + $filters = []; + $viewOnlyFields = $this->formModel->getCustomComponents()['viewOnlyFields']; + + if ($inContactTab) { + $filters[] = ['column' => 'f.inContactTab', 'expr' => 'eq', 'value' => 1]; + } + $formEntities = $this->formModel->getEntities( + [ + 'filter' => ['force' => $filters], + ] + ); + + foreach ($formEntities as $key => $entity) { + $formResults[$key]['entity'] = $entity[0]; + $form = $entity[0]; + $start = 0; + $limit = 999; + $orderBy = 's.date_submitted'; + $orderByDir = 'DESC'; + $filters = []; + $filters[] = ['column' => 's.form_id', 'expr' => 'eq', 'value' => $form->getId()]; + $filters[] = ['column' => 's.lead_id', 'expr' => 'eq', 'value' => $leadId]; + + //get the results + $submissionEntities = $this->getEntities( + [ + 'start' => $start, + 'limit' => $limit, + 'filter' => ['force' => $filters], + 'orderBy' => $orderBy, + 'orderByDir' => $orderByDir, + 'form' => $form, + 'withTotalCount' => true, + ] + ); + + $count = $submissionEntities['count']; + $results = $submissionEntities['results']; + + $formResults[$key]['results'] = $submissionEntities; + $formResults[$key]['content'] = $this->templatingHelper->getTemplating()->render( + 'MauticFormBundle:Result:list-condensed.html.php', + [ + 'items' => $results, + 'filters' => $filters, + 'form' => $form, + 'page' => 1, + 'totalCount' => $count, + 'limit' => $limit, + 'tmpl' => '', + 'canDelete' => false, + 'viewOnlyFields' => $viewOnlyFields, + ] + ); + } + + return $formResults; + } } diff --git a/app/bundles/FormBundle/Views/Result/list-condensed.html.php b/app/bundles/FormBundle/Views/Result/list-condensed.html.php new file mode 100644 index 00000000000..6265a52ce78 --- /dev/null +++ b/app/bundles/FormBundle/Views/Result/list-condensed.html.php @@ -0,0 +1,77 @@ +getId(); + +?> +
    + + + + render('MauticCoreBundle:Helper:tableheader.html.php', [ + 'sessionVar' => 'formresult.'.$formId, + 'text' => 'mautic.form.result.thead.date', + 'class' => 'col-formresult-date', + 'default' => true, + 'dataToggle' => 'date', + ]); + + $fields = $form->getFields(); + $fieldCount = ($canDelete) ? 4 : 3; + foreach ($fields as $f): + if (in_array($f->getType(), $viewOnlyFields) || $f->getSaveResult() === false) { + continue; + } + echo $view->render('MauticCoreBundle:Helper:tableheader.html.php', [ + 'sessionVar' => 'formresult.'.$formId, + 'text' => $f->getLabel(), + 'class' => 'col-formresult-field col-formresult-field'.$f->getId(), + ]); + ++$fieldCount; + endforeach; + ?> + + + + + + trans('mautic.form.form.results.name', ['%id%' => $item['id']]); ?> + + + $r): ?> + + + + + + + + + + + +
    + toFull($item['dateSubmitted']); ?> + > + + + + + + + + + +
    + render('MauticCoreBundle:Helper:noresults.html.php'); ?> +
    +
    diff --git a/app/bundles/LeadBundle/Controller/LeadController.php b/app/bundles/LeadBundle/Controller/LeadController.php index 3918cbd5d7c..8699f904852 100644 --- a/app/bundles/LeadBundle/Controller/LeadController.php +++ b/app/bundles/LeadBundle/Controller/LeadController.php @@ -370,7 +370,7 @@ public function viewAction($objectId) 'integrations' => $integrationRepo->getIntegrationEntityByLead($lead->getId()), 'auditlog' => $this->getAuditlogs($lead), 'doNotContact' => $emailRepo->checkDoNotEmail($fields['core']['email']['value']), - 'leadForms' => $this->getModel('form')->getRepository()->getFormsWithResults($lead->getId(), true), + 'leadForms' => $this->getModel('form.submission')->getFormsWithResults($lead->getId(), true), 'leadNotes' => $this->forward( 'MauticLeadBundle:Note:index', [ diff --git a/app/bundles/LeadBundle/Views/Form/list.html.php b/app/bundles/LeadBundle/Views/Form/list.html.php index b4b40092f5a..809b80d6e51 100644 --- a/app/bundles/LeadBundle/Views/Form/list.html.php +++ b/app/bundles/LeadBundle/Views/Form/list.html.php @@ -3,10 +3,10 @@
  • - + - getName(); ?> + getName(); ?>
  • @@ -15,8 +15,10 @@ -
    - a +
    +
    From 373dd59ab5c7cac1c45329a548a59ae521d2a0a3 Mon Sep 17 00:00:00 2001 From: Zdeno Kuzmany Date: Thu, 8 Feb 2018 01:39:52 +0100 Subject: [PATCH 05/17] Minor --- app/bundles/FormBundle/Model/SubmissionModel.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/bundles/FormBundle/Model/SubmissionModel.php b/app/bundles/FormBundle/Model/SubmissionModel.php index 9b2c7fc1470..5b52997aa0c 100644 --- a/app/bundles/FormBundle/Model/SubmissionModel.php +++ b/app/bundles/FormBundle/Model/SubmissionModel.php @@ -1143,9 +1143,9 @@ protected function validateActionCallbacks(SubmissionEvent $event, &$validationE public function getFormsWithResults($leadId = null, $inContactTab = false) { $formResults = []; - $filters = []; $viewOnlyFields = $this->formModel->getCustomComponents()['viewOnlyFields']; + $filters = []; if ($inContactTab) { $filters[] = ['column' => 'f.inContactTab', 'expr' => 'eq', 'value' => 1]; } From e5f28582e0913f2bc54a0e1dd886a2fc902f6424 Mon Sep 17 00:00:00 2001 From: Zdeno Kuzmany Date: Thu, 8 Feb 2018 02:03:58 +0100 Subject: [PATCH 06/17] Add permission --- .../FormBundle/Model/SubmissionModel.php | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/app/bundles/FormBundle/Model/SubmissionModel.php b/app/bundles/FormBundle/Model/SubmissionModel.php index 5b52997aa0c..5023c796ffe 100644 --- a/app/bundles/FormBundle/Model/SubmissionModel.php +++ b/app/bundles/FormBundle/Model/SubmissionModel.php @@ -1146,9 +1146,21 @@ public function getFormsWithResults($leadId = null, $inContactTab = false) $viewOnlyFields = $this->formModel->getCustomComponents()['viewOnlyFields']; $filters = []; + if ($inContactTab) { $filters[] = ['column' => 'f.inContactTab', 'expr' => 'eq', 'value' => 1]; } + + $permissions = $this->security->isGranted( + ['form:forms:viewown', 'form:forms:viewother'], + 'RETURN_ARRAY' + ); + if ($permissions['form:forms:viewown'] || $permissions['form:forms:viewother']) { + if (!$permissions['form:forms:viewother']) { + $filters[] = ['column' => 'f.createdBy', 'expr' => 'eq', 'value' => $this->userHelper->getUser()->getId()]; + } + } + $formEntities = $this->formModel->getEntities( [ 'filter' => ['force' => $filters], @@ -1179,18 +1191,15 @@ public function getFormsWithResults($leadId = null, $inContactTab = false) ] ); - $count = $submissionEntities['count']; - $results = $submissionEntities['results']; - $formResults[$key]['results'] = $submissionEntities; $formResults[$key]['content'] = $this->templatingHelper->getTemplating()->render( 'MauticFormBundle:Result:list-condensed.html.php', [ - 'items' => $results, + 'items' => $submissionEntities['results'], 'filters' => $filters, 'form' => $form, 'page' => 1, - 'totalCount' => $count, + 'totalCount' => $submissionEntities['count'], 'limit' => $limit, 'tmpl' => '', 'canDelete' => false, From 5b90ae37b197625378bf82fe02c7a447627fd333 Mon Sep 17 00:00:00 2001 From: Zdeno Kuzmany Date: Thu, 8 Feb 2018 02:46:13 +0100 Subject: [PATCH 07/17] Minor final --- .../Translations/en_US/messages.ini | 2 ++ .../LeadBundle/Views/Form/list.html.php | 23 +++++++++++-------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/app/bundles/FormBundle/Translations/en_US/messages.ini b/app/bundles/FormBundle/Translations/en_US/messages.ini index db96ea23386..69c8d091346 100644 --- a/app/bundles/FormBundle/Translations/en_US/messages.ini +++ b/app/bundles/FormBundle/Translations/en_US/messages.ini @@ -130,6 +130,8 @@ mautic.form.form.help.searchcommands="Search commands
    ids: mautic.form.form.kioskmode="Kiosk Mode" mautic.form.form.kioskmode.tooltip="If set to yes, form submissions will not generate new contact tracking cookies or assign the IP address to created/updated contacts." mautic.form.form.contacttab="Show results in contacts tab" +mautic.form.form.contacttab.show.results="Show all results" +mautic.form.form.contacttab.show.form="Show form details" mautic.form.form.contacttab.tooltip="If set to yes, form results will show in contacts detail tab." mautic.form.form.renderstyle="Render Style" mautic.form.form.renderstyle.tooltip="Disable CSS rendering" diff --git a/app/bundles/LeadBundle/Views/Form/list.html.php b/app/bundles/LeadBundle/Views/Form/list.html.php index 809b80d6e51..df10cec0fac 100644 --- a/app/bundles/LeadBundle/Views/Form/list.html.php +++ b/app/bundles/LeadBundle/Views/Form/list.html.php @@ -1,10 +1,10 @@
    - $leadForm): ?> -
    - + From 1c7d54ba99357a9680ac124fb8f942e788c9f428 Mon Sep 17 00:00:00 2001 From: Zdeno Kuzmany Date: Thu, 8 Feb 2018 10:35:07 +0100 Subject: [PATCH 08/17] Improve zero results and minor UX --- app/bundles/FormBundle/Model/SubmissionModel.php | 7 ++++++- app/bundles/FormBundle/Translations/en_US/messages.ini | 4 ++-- .../FormBundle/Views/Result/list-condensed.html.php | 6 ------ app/bundles/LeadBundle/Views/Form/list.html.php | 2 +- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/app/bundles/FormBundle/Model/SubmissionModel.php b/app/bundles/FormBundle/Model/SubmissionModel.php index 5023c796ffe..37f55a17862 100644 --- a/app/bundles/FormBundle/Model/SubmissionModel.php +++ b/app/bundles/FormBundle/Model/SubmissionModel.php @@ -1191,6 +1191,11 @@ public function getFormsWithResults($leadId = null, $inContactTab = false) ] ); + if (empty($submissionEntities['count'])) { + unset($formResults[$key]); + continue; + } + $formResults[$key]['results'] = $submissionEntities; $formResults[$key]['content'] = $this->templatingHelper->getTemplating()->render( 'MauticFormBundle:Result:list-condensed.html.php', @@ -1208,6 +1213,6 @@ public function getFormsWithResults($leadId = null, $inContactTab = false) ); } - return $formResults; + return array_values($formResults); } } diff --git a/app/bundles/FormBundle/Translations/en_US/messages.ini b/app/bundles/FormBundle/Translations/en_US/messages.ini index 69c8d091346..1e3efb2aacb 100644 --- a/app/bundles/FormBundle/Translations/en_US/messages.ini +++ b/app/bundles/FormBundle/Translations/en_US/messages.ini @@ -130,8 +130,8 @@ mautic.form.form.help.searchcommands="Search commands
    ids: mautic.form.form.kioskmode="Kiosk Mode" mautic.form.form.kioskmode.tooltip="If set to yes, form submissions will not generate new contact tracking cookies or assign the IP address to created/updated contacts." mautic.form.form.contacttab="Show results in contacts tab" -mautic.form.form.contacttab.show.results="Show all results" -mautic.form.form.contacttab.show.form="Show form details" +mautic.form.form.contacttab.show.results="Go to all results" +mautic.form.form.contacttab.show.form="Go to form details" mautic.form.form.contacttab.tooltip="If set to yes, form results will show in contacts detail tab." mautic.form.form.renderstyle="Render Style" mautic.form.form.renderstyle.tooltip="Disable CSS rendering" diff --git a/app/bundles/FormBundle/Views/Result/list-condensed.html.php b/app/bundles/FormBundle/Views/Result/list-condensed.html.php index 6265a52ce78..562123f27ce 100644 --- a/app/bundles/FormBundle/Views/Result/list-condensed.html.php +++ b/app/bundles/FormBundle/Views/Result/list-condensed.html.php @@ -65,12 +65,6 @@ - - - - render('MauticCoreBundle:Helper:noresults.html.php'); ?> - - diff --git a/app/bundles/LeadBundle/Views/Form/list.html.php b/app/bundles/LeadBundle/Views/Form/list.html.php index df10cec0fac..14a6af71868 100644 --- a/app/bundles/LeadBundle/Views/Form/list.html.php +++ b/app/bundles/LeadBundle/Views/Form/list.html.php @@ -17,7 +17,7 @@ ?>
    -

    +

    trans('mautic.form.form.contacttab.show.results'); ?>   trans('mautic.form.form.contacttab.show.form'); ?>

    From f7e87418371a4838e150562da98e33c1073680b1 Mon Sep 17 00:00:00 2001 From: Zdeno Kuzmany Date: Thu, 8 Feb 2018 18:13:44 +0100 Subject: [PATCH 09/17] Remove buttons --- app/bundles/FormBundle/Translations/en_US/messages.ini | 2 -- app/bundles/LeadBundle/Views/Form/list.html.php | 5 ----- 2 files changed, 7 deletions(-) diff --git a/app/bundles/FormBundle/Translations/en_US/messages.ini b/app/bundles/FormBundle/Translations/en_US/messages.ini index 1e3efb2aacb..db96ea23386 100644 --- a/app/bundles/FormBundle/Translations/en_US/messages.ini +++ b/app/bundles/FormBundle/Translations/en_US/messages.ini @@ -130,8 +130,6 @@ mautic.form.form.help.searchcommands="Search commands
    ids: mautic.form.form.kioskmode="Kiosk Mode" mautic.form.form.kioskmode.tooltip="If set to yes, form submissions will not generate new contact tracking cookies or assign the IP address to created/updated contacts." mautic.form.form.contacttab="Show results in contacts tab" -mautic.form.form.contacttab.show.results="Go to all results" -mautic.form.form.contacttab.show.form="Go to form details" mautic.form.form.contacttab.tooltip="If set to yes, form results will show in contacts detail tab." mautic.form.form.renderstyle="Render Style" mautic.form.form.renderstyle.tooltip="Disable CSS rendering" diff --git a/app/bundles/LeadBundle/Views/Form/list.html.php b/app/bundles/LeadBundle/Views/Form/list.html.php index 14a6af71868..eb4171ffb99 100644 --- a/app/bundles/LeadBundle/Views/Form/list.html.php +++ b/app/bundles/LeadBundle/Views/Form/list.html.php @@ -17,11 +17,6 @@ ?> From 4d349dfd01d0edc26554142c35c8b7a8027fb199 Mon Sep 17 00:00:00 2001 From: Zdeno Kuzmany Date: Thu, 22 Mar 2018 16:08:18 +0100 Subject: [PATCH 10/17] Fix from review --- app/bundles/FormBundle/Entity/Form.php | 10 ++++------ app/bundles/FormBundle/Model/SubmissionModel.php | 13 +++++-------- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/app/bundles/FormBundle/Entity/Form.php b/app/bundles/FormBundle/Entity/Form.php index 862a8ddd25d..824ae3ae039 100644 --- a/app/bundles/FormBundle/Entity/Form.php +++ b/app/bundles/FormBundle/Entity/Form.php @@ -12,6 +12,7 @@ namespace Mautic\FormBundle\Entity; use Doctrine\Common\Collections\ArrayCollection; +use Doctrine\DBAL\Types\Type; use Doctrine\ORM\Mapping as ORM; use Mautic\ApiBundle\Serializer\Driver\ApiMetadataDriver; use Mautic\CoreBundle\Doctrine\Mapping\ClassMetadataBuilder; @@ -209,10 +210,7 @@ public static function loadMetadata(ORM\ClassMetadata $metadata) ->nullable() ->build(); - $builder->createField('inContactTab', 'boolean') - ->columnName('in_contact_tab') - ->nullable() - ->build(); + $builder->addNullableField('inContactTab', Type::BOOLEAN, 'in_contact_tab'); $builder->createOneToMany('submissions', 'Submission') ->setOrderBy(['dateSubmitted' => 'DESC']) @@ -747,9 +745,9 @@ public function setInKioskMode($inKioskMode) } /** - * @return mixed + * @return bool */ - public function getInContactTab() + public function isInContactTab() { return $this->inContactTab; } diff --git a/app/bundles/FormBundle/Model/SubmissionModel.php b/app/bundles/FormBundle/Model/SubmissionModel.php index 37f55a17862..d70f1543d07 100644 --- a/app/bundles/FormBundle/Model/SubmissionModel.php +++ b/app/bundles/FormBundle/Model/SubmissionModel.php @@ -1132,11 +1132,10 @@ protected function validateActionCallbacks(SubmissionEvent $event, &$validationE } /** - * Return Forms with results to contacts tab - *ľ. + * Return Forms with results to contacts tab. * - * @param null $leadId - * @param bool $inContactTab + * @param int|null $leadId + * @param bool $inContactTab * * @return array */ @@ -1155,10 +1154,8 @@ public function getFormsWithResults($leadId = null, $inContactTab = false) ['form:forms:viewown', 'form:forms:viewother'], 'RETURN_ARRAY' ); - if ($permissions['form:forms:viewown'] || $permissions['form:forms:viewother']) { - if (!$permissions['form:forms:viewother']) { - $filters[] = ['column' => 'f.createdBy', 'expr' => 'eq', 'value' => $this->userHelper->getUser()->getId()]; - } + if ($permissions['form:forms:viewown'] && !$permissions['form:forms:viewother']) { + $filters[] = ['column' => 'f.createdBy', 'expr' => 'eq', 'value' => $this->userHelper->getUser()->getId()]; } $formEntities = $this->formModel->getEntities( From d16e358fc8ae5421ac6aa766b5dd0829bb56cebd Mon Sep 17 00:00:00 2001 From: Zdeno Kuzmany Date: Thu, 22 Mar 2018 16:11:05 +0100 Subject: [PATCH 11/17] Added default switch to No --- app/bundles/FormBundle/Form/Type/FormType.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/bundles/FormBundle/Form/Type/FormType.php b/app/bundles/FormBundle/Form/Type/FormType.php index 68fb779a0f4..fe04596afe4 100644 --- a/app/bundles/FormBundle/Form/Type/FormType.php +++ b/app/bundles/FormBundle/Form/Type/FormType.php @@ -111,6 +111,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) 'attr' => [ 'tooltip' => 'mautic.form.form.contacttab.tooltip', ], + 'data'=> $options['data']->isInContactTab() ? true : false, ]); // Render style for new form by default From decaed4b3682242070eec149dc79e97ab40abed2 Mon Sep 17 00:00:00 2001 From: Zdeno Kuzmany Date: Thu, 22 Mar 2018 16:12:42 +0100 Subject: [PATCH 12/17] Limit results from 999 to 99 (Wayne Gretzky commit) --- app/bundles/FormBundle/Model/SubmissionModel.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/bundles/FormBundle/Model/SubmissionModel.php b/app/bundles/FormBundle/Model/SubmissionModel.php index d70f1543d07..68afecf97ae 100644 --- a/app/bundles/FormBundle/Model/SubmissionModel.php +++ b/app/bundles/FormBundle/Model/SubmissionModel.php @@ -1168,7 +1168,7 @@ public function getFormsWithResults($leadId = null, $inContactTab = false) $formResults[$key]['entity'] = $entity[0]; $form = $entity[0]; $start = 0; - $limit = 999; + $limit = 99; $orderBy = 's.date_submitted'; $orderByDir = 'DESC'; $filters = []; From 623c2e843305988cf5e4ef6f0041ff87a9378f3d Mon Sep 17 00:00:00 2001 From: Zdeno Kuzmany Date: Thu, 22 Mar 2018 22:10:45 +0100 Subject: [PATCH 13/17] Fixed review minor issues --- app/bundles/FormBundle/Entity/Form.php | 2 +- app/bundles/FormBundle/Model/SubmissionModel.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/bundles/FormBundle/Entity/Form.php b/app/bundles/FormBundle/Entity/Form.php index 824ae3ae039..46ba517901e 100644 --- a/app/bundles/FormBundle/Entity/Form.php +++ b/app/bundles/FormBundle/Entity/Form.php @@ -753,7 +753,7 @@ public function isInContactTab() } /** - * @param mixed $inContactTab + * @param bool $inContactTab */ public function setInContactTab($inContactTab) { diff --git a/app/bundles/FormBundle/Model/SubmissionModel.php b/app/bundles/FormBundle/Model/SubmissionModel.php index 68afecf97ae..127673326c3 100644 --- a/app/bundles/FormBundle/Model/SubmissionModel.php +++ b/app/bundles/FormBundle/Model/SubmissionModel.php @@ -1134,12 +1134,12 @@ protected function validateActionCallbacks(SubmissionEvent $event, &$validationE /** * Return Forms with results to contacts tab. * - * @param int|null $leadId - * @param bool $inContactTab + * @param int $leadId + * @param bool $inContactTab * * @return array */ - public function getFormsWithResults($leadId = null, $inContactTab = false) + public function getFormsWithResults($leadId, $inContactTab = false) { $formResults = []; $viewOnlyFields = $this->formModel->getCustomComponents()['viewOnlyFields']; From 86f0cdfbf921b358a2726ef5c6a39ac280610023 Mon Sep 17 00:00:00 2001 From: Zdeno Kuzmany Date: Fri, 23 Mar 2018 12:25:13 +0100 Subject: [PATCH 14/17] Minor html style --- app/bundles/LeadBundle/Views/Form/list.html.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/bundles/LeadBundle/Views/Form/list.html.php b/app/bundles/LeadBundle/Views/Form/list.html.php index eb4171ffb99..ddfa94615ac 100644 --- a/app/bundles/LeadBundle/Views/Form/list.html.php +++ b/app/bundles/LeadBundle/Views/Form/list.html.php @@ -1,11 +1,11 @@