This commit is contained in:
root 2017-06-19 17:41:42 +02:00
parent 8c13f2ddba
commit 72cee7b991
9 changed files with 11 additions and 222 deletions

View File

@ -1,58 +0,0 @@
<?php
class addCustomer extends Module
{
public function __construct()
{
$this->name = 'addcustomer';
$this->tab = 'front_office_feature';
$this->version = '1.0';
$this->author = 'Antadis';
$this->need_instance = 0;
$this->ps_versions_compliance = array('min' => '1.5', 'max' => _PS_VERSION_);
parent::__construct();
$this->displayName = $this->l('Add customer');
$this->description = $this->l('Ajout de client pouvant passer des commandes pro.');
$this->confirmUninstall = $this->l('Are you sure you want to uninstall this module?');
}
public function install()
{
return parent::install() && $this->registerHook('DisplayHomeAddCusto') && $this->registerHook('moduleRoutes');
}
public function hookDisplayHomeAddCusto($params)
{
$this->context->smarty->assign(
array(
'formLink' => $this->context->link->getModuleLink('addcustomer', 'form'),
)
);
return $this->display(__FILE__, 'views/templates/hook/addcustomer.tpl');
}
public function hookModuleRoutes($params)
{
return [
'module-addcustomer-form' => [
'controller' => 'form',
'rule' => 'ouverture-compte.html',
'keywords' => [
'code'=> array(
'regexp'=>'[\w]+',
'param'=>'short_code'
)
],
'params' => [
'fc' => 'module',
'module' => 'addcustomer',
'controller' => 'form'
]
]
];
}
}

View File

@ -1,80 +0,0 @@
<?php
class addCustomerFormModuleFrontController extends ModuleFrontController
{
public $errors = null;
public function initContent()
{
if (Tools::isSubmit('SubmitRegister')) {
$this->processRequest();
if (empty($this->errors)) {
$this->sendMail();
}
}
$this->context->smarty->assign(
array(
'hasError' => !empty($this->errors),
'errors' => $this->errors,
)
);
parent::initContent();
$this->setTemplate('form.tpl');
}
private function processRequest()
{
if (!Tools::getValue('lastName')) {
$this->errors = Tools::displayError('Un nom est requis');
} elseif (!Validate::isName(Tools::getValue('lastName'))) {
$this->errors = Tools::displayError('Veuillez renseigner un nom correct');
} elseif (!Tools::getValue('firstName')) {
$this->errors = Tools::displayError('Un prenom est requis');
} elseif (!Validate::isName(Tools::getValue('firstName'))) {
$this->errors = Tools::displayError('Veuillez renseigner un prenom correct');
} elseif (!Tools::getValue('phoneNumber')) {
$this->errors = Tools::displayError('Un numéro est requis');
} elseif (!$this->isPhoneNumber(Tools::getValue('phoneNumber'))) {
$this->errors = Tools::displayError('Veuillez renseigner un numéro correct');
} elseif (!Tools::getValue('email')) {
$this->errors = Tools::displayError('Une adresse mail est requise');
} elseif (!Validate::isEmail(Tools::getValue('email'))) {
$this->errors = Tools::displayError('Veuillez renseigner une adresse mail correct');
} elseif (!Tools::getValue('name')) {
$this->errors = Tools::displayError('Un nom d\'entrerpise est requise');
} elseif (!Validate::isAnything(Tools::getValue('name'))) {
$this->errors = Tools::displayError('Veuillez renseigner un nom d\'entrerpise correct');
} elseif (!Tools::getValue('siret')) {
$this->errors = Tools::displayError('Un SIRET est requise');
} elseif (!Validate::isSiret(Tools::getValue('siret'))) {
$this->errors = Tools::displayError('Veuillez renseigner un SIRET correct');
}
}
private function sendMail()
{
global $cookie;
$subject = 'Demande d\'accès à l\'espace professionnel';
$data = array(
'{lastName}' => Tools::getValue('lastName'),
'{firstName}' => Tools::getValue('firstName'),
'{phoneNumber}' => Tools::getValue('phoneNumber'),
'{email}' => Tools::getValue('email'),
'{name}' => Tools::getValue('name'),
'{siret}' => Tools::getValue('siret'),
);
$dest = 'tarlowski@antadis.com';
Mail::Send(intval($cookie->id_lang), 'addcustomer', $subject, $data, $dest, null, null, null, null, null, 'modules/addcustomer/mails/');
}
private function isPhoneNumber($number)
{
return preg_match('/^[+0-9. ()-]{10}$/', $number);
}
}

View File

@ -1 +0,0 @@
<h1>{l s='test' mod='addcustomer'}</h1>

View File

@ -1,62 +0,0 @@
<header class="page-heading">
<div class="ctn">
<h1>Inscription espace professionnel</h1>
</div>
</header>
<div id="auth" class="ctn">
<div class="row">
<div class="offset-lg3 lg6 offset-md2 md8 sm12">
{if $hasError === true}
<div class="displayError">
<p>{$errors}</p>
</div>
{/if}
{if $errors === null || $hasError === true}
<form action="#" method="post" class="box" id="login_form">
<div class="inner">
<div class="box-content clearfix">
<div class="form-group">
<label for="email">Nom</label>
<input type="text" name="lastName">
</div>
<div class="form-group">
<label for="email">Prenom</label>
<input type="text" name="firstName">
</div>
<div class="form-group">
<label for="email">Numéro de téléphone</label>
<input type="tel" name="phoneNumber">
</div>
<div class="form-group">
<label for="email">Adresse e-mail</label>
<input type="email" name="email">
</div>
<div class="form-group">
<label for="email">Nom de l'entreprise</label>
<input type="text" name="name">
</div>
<div class="form-group">
<label for="email">SIRET de l'entreprise</label>
<input type="number" name="siret">
</div>
<button type="submit" id="SubmitLogin" name="SubmitRegister" class="btn btn-full-width no-icon">
<span>envoyer</span>
</button>
</div>
</div>
</form>
{else}
<div class="displayError">
<p>{l s='Merci un conseiller prendra contact avec vous rapidement' mod='addcustomer'}</p>
</div>
{/if}
</div>
</div>
</div>
<!--
Nom
Prenom
Tel ()
Mail
Nom entreprise ()
SIRET (*) -->

View File

@ -1,3 +0,0 @@
<br><br>
<h2 class="title">Pas encore inscrit ?</h2>
<a class="lost_password" href="{$formLink}">Demander un accès à l'espace professionnel</a>

View File

@ -3,14 +3,13 @@ define('ANTADIS_CHECK_GROUPS', true);
class FrontController extends FrontControllerCore
{
public function display()
{
global $cookie;
if (empty($cookie->tmp)) {
$cookie->tmp = serialize($this->errors);
}
if (defined('ANTADIS_CHECK_GROUPS') && ANTADIS_CHECK_GROUPS) {
$id_customer_group = Configuration::get('PS_CUSTOMER_GROUP');
if ($id_customer_group!==FALSE && (int)$id_customer_group>0) {
@ -37,25 +36,20 @@ class FrontController extends FrontControllerCore
}
/*
// * Force assign template
// */
if (!$cookie->isLogged()
&& (!Context::getContext()->controller instanceOf addCustomerFormModuleFrontController)
) {
* Force assign template
*/
if (!$cookie->isLogged()) {
$this->template = _PS_THEME_DIR_.'authentication.tpl';
if ($this->php_self == 'password') {
$this->php_self = 'index';
$this->template = _PS_THEME_DIR_.'password.tpl';
}
if (!in_array($this->php_self, ['index', 'password'])
|| Tools::getValue('submitAccount')
|| Tools::getValue('SubmitCreate')) {
if (!in_array($this->php_self, ['index', 'password']) || Tools::getValue('submitAccount') || Tools::getValue('SubmitCreate')) {
Tools::redirect('index');
exit;
}
}
}
Tools::safePostVars();
// assign css_files and js_files at the very last time
@ -72,7 +66,7 @@ class FrontController extends FrontControllerCore
/* Override destroy all css */
$this->css_files = array();
// Override Add real css
/* Override Add real css */
$this->css_files[_THEME_CSS_DIR_.'strapivarious.css?v='.filemtime($this->getThemeDir().'css/strapivarious.css')] = 'all';
$this->css_files[_THEME_CSS_DIR_.'k2000.css?v='.filemtime($this->getThemeDir().'css/k2000.css')] = 'all';
$this->css_files[_THEME_CSS_DIR_.'global.css?v='.filemtime($this->getThemeDir().'css/global.css')] = 'all';
@ -153,7 +147,7 @@ class FrontController extends FrontControllerCore
$entity = $this->php_self;
if (!$cookie->isLogged()
&& (!Context::getContext()->controller instanceOf addCustomerFormModuleFrontController)) {
if (!in_array($this->php_self, ['index', 'password']) || Tools::getValue('submitAccount') || Tools::getValue('SubmitCreate')) {
if (!in_array($this->php_self, ['index', 'password']) || Tools::getValue('submitAccount') || Tools::getValue('SubmitCreate')) {
Tools::redirect('index');
exit;
}

View File

@ -41,7 +41,6 @@
{l s='Forgot your password?'}
</a>
</div>
{hook h="DisplayHomeAddCusto"}
</div>
</form>
</div>

View File

@ -1,5 +1,5 @@
{if !isset($content_only) || !$content_only}
{if $page_name != 'category' && $page_name != 'index' && $page_name != 'search' && $page_name != 'password' && $page_name != 'module-addcustomer-form'}
{if $page_name != 'category' && $page_name != 'index' && $page_name != 'search' && $page_name != 'password'}
<footer id="footer">
<div class="ctn">
{hook h='displayReassurance'}

View File

@ -50,7 +50,7 @@
</div>
{/if}
{$page_array = ['index', 'password', 'module-addcustomer-form']}
{$page_array = ['index', 'password']}
<header id="header">
<div class="ctn">