From: Vincent Vanwaelscappel Date: Thu, 27 Mar 2025 19:03:26 +0000 (+0100) Subject: wip #7375 @2 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=1239d26e6a1573eea2c5597a063af7a76d742dbd;p=dtlc.git wip #7375 @2 --- diff --git a/framework/application/controllers/AjaxController.php b/framework/application/controllers/AjaxController.php index ad0df41..3e50c5a 100644 --- a/framework/application/controllers/AjaxController.php +++ b/framework/application/controllers/AjaxController.php @@ -1,70 +1,96 @@ 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', '
' . $_POST['confirmation'] . '
'); - $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', '
' . $_POST['confirmation'] . '
'); + $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', '
' . $_POST['confirmation'] . '
'); + $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()); + } } diff --git a/framework/application/forms/Devis.php b/framework/application/forms/Devis.php index a7535ad..b7cc604 100644 --- a/framework/application/forms/Devis.php +++ b/framework/application/forms/Devis.php @@ -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() diff --git a/less/devis/form.less b/less/devis/form.less index 6698b35..19b64f2 100644 --- a/less/devis/form.less +++ b/less/devis/form.less @@ -1,6 +1,12 @@ #devis { margin: 30px 0 20px; + #wrap-fax{ + visibility: hidden; + width: 0; + height: 0; + } + fieldset { background: #fff; padding: 20px;