<?php
-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)) {
- $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', '<div id="confirmationQuote" style="background-color:#fff">' . $okmessage . '</div>');
+ $this->_datas->addReplace('#' . $formID . 'Wrapper', '<div id="confirmationQuote" style="background-color:#fff">' . $okmessage . '</div>');
} else {
$this->_datas->addReplace('#' . $formID, '<div id="confirmationQuote">' . $okmessage . '</div>');
}
- $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');
+ }
- }
+ }
}