From c307cbeac37ffdf0ca0670e4aeba82940fdc8675 Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Fri, 10 Apr 2020 08:12:27 +0000 Subject: [PATCH] fix #3393 @0.25 --- .../controllers/AjaxController.php | 74 ++++++++++--------- .../controllers/IndexController.php | 12 ++- 2 files changed, 50 insertions(+), 36 deletions(-) diff --git a/framework/application/controllers/AjaxController.php b/framework/application/controllers/AjaxController.php index 63651f8..af668d1 100644 --- a/framework/application/controllers/AjaxController.php +++ b/framework/application/controllers/AjaxController.php @@ -1,45 +1,51 @@ setId($formID); - $form->setAction($form->getAction() . '/' . $formID); - } else { - $formID = $form->getId(); - } - - if ($form->isValid($_POST)) { - $url = 'https://workshop.fluidbook.com/ajax/demandeDevis?devis_form=' . base64_encode(json_encode($_POST)); - $xml = simplexml_load_file($url); - $xml_alert = $xml->xpath('//alert'); - - $okmessage = array_pop($xml_alert); - if (null !== $okmessage) { - $okmessage = (string)$okmessage->content; - } - - // If we're processing the popup form, the success message will replace the whole section including the text +class AjaxController extends CubeIT_Controller_AjaxController +{ + + public function requestQuote($formID = null) + { + $form = new Fluidbook_Form_RequestQuote(); + + // Take form ID from URL so we can differentiate between the popup and the embedded versions of the form + if ($formID) { + $form->setId($formID); + $form->setAction($form->getAction() . '/' . $formID); + } else { + $formID = $form->getId(); + } + + if ($form->isValid($_POST)) { + $data = $_POST; + if (isset(Bootstrap::getInstance()->getSession()->gclid)) { + $data['gclid'] = Bootstrap::getInstance()->getSession()->gclid; + } + $url = 'https://workshop.fluidbook.com/ajax/demandeDevis?devis_form=' . base64_encode(json_encode($data)); + $xml = simplexml_load_file($url); + $xml_alert = $xml->xpath('//alert'); + + $okmessage = array_pop($xml_alert); + if (null !== $okmessage) { + $okmessage = (string)$okmessage->content; + } + + // If we're processing the popup form, the success message will replace the whole section including the text // Otherwise, just the form itself is replaced. - if ($formID == 'requestQuotePopup') { - // Todo: work out why CSS isn't taking effect (see #confirmationQuote in 315-quote.less) - using inline CSS for now. + if ($formID == 'requestQuotePopup') { + // Todo: work out why CSS isn't taking effect (see #confirmationQuote in 315-quote.less) - using inline CSS for now. // Todo: see issue https://team.cubedesigners.com/redmine/issues/737 for possible cause - $this->_datas->addReplace('#' . $formID .'Wrapper', '
' . $okmessage . '
'); + $this->_datas->addReplace('#' . $formID . 'Wrapper', '
' . $okmessage . '
'); } else { $this->_datas->addReplace('#' . $formID, '
' . $okmessage . '
'); } - $this->_datas->addGAEvent('form', 'sent', 'quote'); - } else { - $this->_datas->refreshForm($form); // Respond with validation errors - $this->_datas->addAction('eval', "displayErrors('$formID')"); - $this->_datas->addGAEvent('form', 'error', 'quote'); - } + $this->_datas->addGAEvent('form', 'sent', 'quote'); + } else { + $this->_datas->refreshForm($form); // Respond with validation errors + $this->_datas->addAction('eval', "displayErrors('$formID')"); + $this->_datas->addGAEvent('form', 'error', 'quote'); + } - } + } } diff --git a/framework/application/controllers/IndexController.php b/framework/application/controllers/IndexController.php index d4df531..86dcaf7 100644 --- a/framework/application/controllers/IndexController.php +++ b/framework/application/controllers/IndexController.php @@ -1,6 +1,14 @@ getSession()->gclid = $_GET['gclid']; + } + parent::init(); // TODO: Change the autogenerated stub + + } } -- 2.39.5