divers
This commit is contained in:
parent
47f206a351
commit
a31bb7105a
@ -1,58 +1,59 @@
|
||||
<?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'
|
||||
]
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
<?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'
|
||||
]
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -1,80 +1,70 @@
|
||||
<?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);
|
||||
}
|
||||
|
||||
}
|
||||
<?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 (!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 (!Validate::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()
|
||||
{
|
||||
$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 = 'thibault@antadis.com';
|
||||
|
||||
Mail::Send(intval(Context::getContext()->language->id), 'addcustomer', $subject, $data, $dest, null, null, null, null, null, 'modules/addcustomer/mails/');
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,62 +1,55 @@
|
||||
<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 (*) -->
|
||||
<header class="page-heading">
|
||||
<div class="ctn">
|
||||
<h1>{l s='Inscription espace professionnel' mod='addcustomer'}</h1>
|
||||
</div>
|
||||
</header>
|
||||
{if $hasError === true}
|
||||
<div class="alert alert-danger displayError">
|
||||
<p>{$errors}</p>
|
||||
</div>
|
||||
{/if}
|
||||
<div id="auth" class="ctn">
|
||||
<div class="row">
|
||||
<div class="offset-lg3 lg6 offset-md2 md8 sm12">
|
||||
{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">{l s='Nom' mod='addcustomer'}</label>
|
||||
<input type="text" name="lastName" class="account_input form-control" {if ($smarty.post.lastName)} value="{$smarty.post.lastName}"{/if}>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="email">{l s='Prenom' mod='addcustomer'}</label>
|
||||
<input type="text" name="firstName" class="account_input form-control" {if ($smarty.post.firstName)} value="{$smarty.post.firstName}"{/if}>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="email">{l s='Numéro de téléphone' mod='addcustomer'} <sup>*</sup></label>
|
||||
<input type="tel" required name="phoneNumber" class="account_input form-control" {if ($smarty.post.phoneNumber)} value="{$smarty.post.phoneNumber}"{/if}>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="email">{l s='Adresse e-mail' mod='addcustomer'} <sup>*</sup></label>
|
||||
<input type="email" required name="email" class="account_input form-control" {if ($smarty.post.email)} value="{$smarty.post.email}"{/if}>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="email">{l s='Nom de l\'entreprise' mod='addcustomer'} <sup>*</sup></label>
|
||||
<input type="text" required name="name" class="account_input form-control" {if ($smarty.post.name)} value="{$smarty.post.name}"{/if}>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="email">{l s='SIRET de l\'entreprise' mod='addcustomer'} <sup>*</sup></label>
|
||||
<input type="text" required name="siret" class="account_input form-control" {if ($smarty.post.siret)} value="{$smarty.post.siret}"{/if}>
|
||||
</div>
|
||||
<button type="submit" id="SubmitLogin" name="SubmitRegister" class="btn btn-full-width no-icon">
|
||||
<span>{l s='envoyer' mod='addcustomer'}</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>
|
@ -1,3 +1,4 @@
|
||||
<br><br>
|
||||
<h2 class="title">Pas encore inscrit ?</h2>
|
||||
<a class="lost_password" href="{$formLink}">Demander un accès à l'espace professionnel</a>
|
||||
<div style="margin-top:30px;">
|
||||
<h2 class="title">{l s='Pas encore inscrit ?' mod='addcustomer'}</h2>
|
||||
<a class="lost_password" href="{$formLink}">{l s='Demander un accès à l \'espace professionnel' mod='addcustomer'}</a>
|
||||
</div>
|
Loading…
Reference in New Issue
Block a user