]> _ Git - dtlc.git/commitdiff
wip #7375 @2
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 27 Mar 2025 19:03:26 +0000 (20:03 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 27 Mar 2025 19:03:26 +0000 (20:03 +0100)
framework/application/controllers/AjaxController.php
framework/application/forms/Devis.php
less/devis/form.less

index ad0df41c0c8ceb3a1db820f1aa0cc6eef604221a..3e50c5a58415cf456cf9936c183716ea87710a9b 100644 (file)
@@ -1,70 +1,96 @@
 <?php
 
-class AjaxController extends CubeIT_Controller_AjaxController {
+class AjaxController extends CubeIT_Controller_AjaxController
+{
 
-       public function devis() {
-               $form = new DTLC_Form_Devis();
-               $this->saveFormDevis();
-               if ($form->isValid($_POST)) {
-                       $db = $this->getDb();
-                       $bind = $_POST;
-                       // Add current date
-                       $bind['date'] = Zend_Date::now();
-                       // Choose randomly the boutique if the client don't make any choice
-                       if ($bind['magasin'] == 'indif') {
-                               $magasins = DTLC_Util::getMagasins();
-                               shuffle($magasins);
-                               $bind['magasin'] = $magasins[0]['id'];
-                       }
-                       $db->compliantInsert('devis', $bind);
-                       $bind['id'] = $db->lastInsertId('devis');
-                       $this->_mailSendDevis($bind);
-                       $this->addContent('devis', '<fieldset>' . $_POST['confirmation'] . '</fieldset>');
-                       $this->clearFormDevis();
-               } else {
-                       $form->setDefaults($_POST);
-                       $this->addScrollTo('#devis', 0.5);
-                       $this->addReplace('#devis', $form->render());
-               }
-       }
+    public function devis()
+    {
+        $form = new DTLC_Form_Devis();
+        $this->saveFormDevis();
 
-       public function _mailSendDevis($devis) {
-               $mail = new CubeIT_Mail();
-               $mail->setFrom('contact@detouteslescouleurs.com');
-               $mail->addTo(DTLC_Util::getMagasinById($devis['magasin'])['email_trans']);
-               $mail->setSubject('[DTLC.com] Demande de devis #' . $devis['id']);
-               $text = 'Pour consulter et réaliser le devis, veuillez vous rendre à l\'adresse ci-dessous : ' . "\n";
-               $text .= 'https://' . $this->getOption('webhost') . '/admin/devis/' . $devis['id'];
-               $mail->setBodyText($text);
-               $mail->send();
-       }
+        if (isset($_POST['fax']) && $_POST['fax']) {
+            $this->_mailSendSpamDevis($_POST);
+            $this->addContent('devis', '<fieldset>' . $_POST['confirmation'] . '</fieldset>');
+            $this->clearFormDevis();
+            return;
+        }
 
-       public function saveFormDevis() {
-               $session = $this->getSession();
-               if (!isset($_POST['nom'])) {
-                       return;
-               }
-               $session->formDevis = $_POST;
-       }
+        if ($form->isValid($_POST)) {
+            $db = $this->getDb();
+            $bind = $_POST;
+            // Add current date
+            $bind['date'] = Zend_Date::now();
+            // Choose randomly the boutique if the client don't make any choice
+            if ($bind['magasin'] == 'indif') {
+                $magasins = DTLC_Util::getMagasins();
+                shuffle($magasins);
+                $bind['magasin'] = $magasins[0]['id'];
+            }
+            $db->compliantInsert('devis', $bind);
+            $bind['id'] = $db->lastInsertId('devis');
+            $this->_mailSendDevis($bind);
+            $this->addContent('devis', '<fieldset>' . $_POST['confirmation'] . '</fieldset>');
+            $this->clearFormDevis();
+        } else {
+            $form->setDefaults($_POST);
+            $this->addScrollTo('#devis', 0.5);
+            $this->addReplace('#devis', $form->render());
+        }
+    }
 
-       public function clearFormDevis() {
-               $session = $this->getSession();
-               unset($session->formDevis);
-       }
+    public function _mailSendDevis($devis)
+    {
+        $mail = new CubeIT_Mail();
+        $mail->setFrom('contact@detouteslescouleurs.com');
+        $mail->addTo(DTLC_Util::getMagasinById($devis['magasin'])['email_trans']);
+        $mail->setSubject('[DTLC.com] Demande de devis #' . $devis['id']);
+        $text = 'Pour consulter et réaliser le devis, veuillez vous rendre à l\'adresse ci-dessous : ' . "\n";
+        $text .= 'https://' . $this->getOption('webhost') . '/admin/devis/' . $devis['id'];
+        $mail->setBodyText($text);
+        $mail->send();
+    }
 
-       public function refreshFormDevis($add = false, $save = true) {
-               if ($save) {
-                       $this->saveFormDevis();
-               }
+    public function _mailSendSpamDevis($devis)
+    {
+        $mail = new CubeIT_Mail();
+        $mail->setFrom('contact@detouteslescouleurs.com');
+        $mail->addTo(DTLC_Util::getMagasinById($devis['magasin'])['email_trans']);
+        $mail->setSubject('[DTLC.com] ** SPAM ** Demande de devis');
+        $text = 'Cette demande est suspectée d\'être un spam : ' . "\n";
+        $text .= json_encode($devis);
+        $mail->setBodyText($text);
+        $mail->send();
+    }
 
-               $session = $this->getSession();
+    public function saveFormDevis()
+    {
+        $session = $this->getSession();
+        if (!isset($_POST['nom'])) {
+            return;
+        }
+        $session->formDevis = $_POST;
+    }
 
-               $form = new DTLC_Form_Devis();
-               $form->setDefaults($_POST);
-               if ($add) {
-                       $form->getSubForm('demandes')->addDemande();
-               }
-               $this->addReplace('#devis', $form->render());
-       }
+    public function clearFormDevis()
+    {
+        $session = $this->getSession();
+        unset($session->formDevis);
+    }
+
+    public function refreshFormDevis($add = false, $save = true)
+    {
+        if ($save) {
+            $this->saveFormDevis();
+        }
+
+        $session = $this->getSession();
+
+        $form = new DTLC_Form_Devis();
+        $form->setDefaults($_POST);
+        if ($add) {
+            $form->getSubForm('demandes')->addDemande();
+        }
+        $this->addReplace('#devis', $form->render());
+    }
 
 }
index a7535adca47f6a71eeb269da6abc3e848507cf3a..b7cc604e737486b12f4401bc8ed21b8ca4baf0ef 100644 (file)
@@ -313,6 +313,10 @@ class DTLC_Form_Devis extends CubeIT_Form_List
         $telephone->addValidator($notEmptyValidator);
         $this->addElement($telephone);
 
+        $fax = new CubeIT_Form_Element_Phone('fax');
+        $fax->setLabel('Fax');
+        $this->addElement($fax);
+
         $mobile = new CubeIT_Form_Element_Phone('mobile');
         $mobile->setLabel('Mobile');
         $this->addElement($mobile);
@@ -365,7 +369,7 @@ class DTLC_Form_Devis extends CubeIT_Form_List
         $this->addElement($reference);
 
         $legend = $this->getAdmin() ? 'Coordonnées' : 'Vos coordonnées';
-        $this->addDisplayGroup(array('societe', 'prenom', 'nom', 'telephone', 'mobile', 'email', 'reference', 'adresse', 'code_postal', 'ville', 'pays', 'tva_intra'), 'coordonnees', array('legend' => $legend));
+        $this->addDisplayGroup(array('societe', 'prenom', 'nom', 'telephone','fax', 'mobile', 'email', 'reference', 'adresse', 'code_postal', 'ville', 'pays', 'tva_intra'), 'coordonnees', array('legend' => $legend));
     }
 
     protected function _setDemandes()
index 6698b35ddb1eab8b638dbb4e7e8913d587f06106..19b64f2ccaac3aab957df7986b73132d89dd7726 100644 (file)
@@ -1,6 +1,12 @@
 #devis {
   margin: 30px 0 20px;
 
+  #wrap-fax{
+    visibility: hidden;
+    width: 0;
+    height: 0;
+  }
+
   fieldset {
     background: #fff;
     padding: 20px;