<?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());
+ }
}
$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);
$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()