Error management

This commit is contained in:
Alexandre Simonet 2016-02-24 10:35:05 +01:00
parent fdb6a5ddad
commit 33bd6c01c4
5 changed files with 91 additions and 59 deletions

View File

@ -21,39 +21,41 @@ class Process
$errors[] = 'All fields are not filled';
}
$query = Db::getInstance()->autoExecute(_DB_PREFIX_.'contactform', [
'brand' => pSQL($this->data['brand']),
'compagny' => pSQL($this->data['compagny']),
'lastname' => pSQL($this->data['lastname']),
'firstname' => pSQL($this->data['firstname']),
'function' => pSQL($this->data['function']),
'email1' => pSQL($this->data['email1']),
'email2' => pSQL($this->data['email2']),
'phone1' => pSQL($this->data['phone1']),
'phone2' => pSQL($this->data['phone2']),
'purpose' => pSQL($this->data['purpose']),
'content' => pSQL($this->data['content']),
'type' => Contactform::TYPE_PROVIDER
], 'INSERT');
if ($isCorrect) {
$query = Db::getInstance()->autoExecute(_DB_PREFIX_.'contactform', [
'brand' => pSQL($this->data['brand']),
'compagny' => pSQL($this->data['compagny']),
'lastname' => pSQL($this->data['lastname']),
'firstname' => pSQL($this->data['firstname']),
'function' => pSQL($this->data['function']),
'email1' => pSQL($this->data['email1']),
'email2' => pSQL($this->data['email2']),
'phone1' => pSQL($this->data['phone1']),
'phone2' => pSQL($this->data['phone2']),
'purpose' => pSQL($this->data['purpose']),
'content' => pSQL($this->data['content']),
'type' => Contactform::TYPE_PROVIDER
], 'INSERT');
if (!$query) {
$errors[] = "something went wrong";
if (!$query) {
$errors[] = "something went wrong";
}
Mail::Send(
intval($cookie->id_lang),
'provider',
'sujet',
$this->data,
$this->to,
NULL,
NULL,
NULL,
NULL,
NULL,
$this->mail_dir
);
}
Mail::Send(
intval($cookie->id_lang),
'provider',
'sujet',
$this->data,
$this->to,
NULL,
NULL,
NULL,
NULL,
NULL,
$this->mail_dir
);
if (!empty($errors)) {
return $errors;
}
@ -69,38 +71,40 @@ class Process
$errors[] = 'All fields are not filled';
}
$query = Db::getInstance()->autoExecute(_DB_PREFIX_.'contactform', [
'compagny' => pSQL($this->data['compagny']),
'lastname' => pSQL($this->data['lastname']),
'firstname' => pSQL($this->data['firstname']),
'function' => pSQL($this->data['function']),
'email1' => pSQL($this->data['email1']),
'email2' => pSQL($this->data['email2']),
'phone1' => pSQL($this->data['phone1']),
'phone2' => pSQL($this->data['phone2']),
'content' => pSQL($this->data['content']),
'type' => Contactform::TYPE_PRESS
], 'INSERT');
if ($isCorrect) {
$query = Db::getInstance()->autoExecute(_DB_PREFIX_.'contactform', [
'compagny' => pSQL($this->data['compagny']),
'lastname' => pSQL($this->data['lastname']),
'firstname' => pSQL($this->data['firstname']),
'function' => pSQL($this->data['function']),
'email1' => pSQL($this->data['email1']),
'email2' => pSQL($this->data['email2']),
'phone1' => pSQL($this->data['phone1']),
'phone2' => pSQL($this->data['phone2']),
'content' => pSQL($this->data['content']),
'type' => Contactform::TYPE_PRESS
], 'INSERT');
if (!$query) {
$errors[] = "something went wrong";
if (!$query) {
$errors[] = "something went wrong";
}
Mail::Send(
intval($cookie->id_lang),
'press',
'sujet',
$this->data,
$this->to,
NULL,
NULL,
NULL,
NULL,
NULL,
$this->mail_dir
);
}
Mail::Send(
intval($cookie->id_lang),
'press',
'sujet',
$this->data,
$this->to,
NULL,
NULL,
NULL,
NULL,
NULL,
$this->mail_dir
);
if (!empty($errors)) {
return $errors;
}

View File

@ -7,11 +7,14 @@ include_once(dirname(__FILE__).'/contactform.php');
include_once(dirname(__FILE__).'/Process.php');
include(dirname(__FILE__).'/../../header.php');
$result = null;
if (!empty($_POST['type'])) {
$Process = new Process();
$result = $Process->addPress($_POST);
}
$smarty->assign('result', $result);
$smarty->assign('_POST', $_POST);
echo Module::display(dirname(__FILE__).'/contactform.php', 'press.tpl');

View File

@ -8,6 +8,16 @@
<div class="sheets" style="padding: 20px 20px;">
<div id="idTab1">
{if $_POST}
{if $result|is_array}
{foreach from=$result item=error}
<p class="bold" style="color: red">{$error}</p>
{/foreach}
{else}
<p class="bold">Your request was sended</p>
{/if}
{/if}
<form action="/modules/contactform/press.php" method="post">
<label for="compagny">{l s='compagny' mod='contactform'}*</label>

View File

@ -7,11 +7,15 @@ include_once(dirname(__FILE__).'/contactform.php');
include_once(dirname(__FILE__).'/Process.php');
include(dirname(__FILE__).'/../../header.php');
$result = null;
if (!empty($_POST['type'])) {
$Process = new Process();
$result = $Process->addProvider($_POST);
}
$smarty->assign('result', $result);
$smarty->assign('_POST', $_POST);
echo Module::display(dirname(__FILE__).'/contactform.php', 'provider.tpl');

View File

@ -6,6 +6,17 @@
</ul>
<div class="sheets" style="padding: 20px 20px;">
<div id="idTab1">
{if $_POST}
{if $result|is_array}
{foreach from=$result item=error}
<p class="bold" style="color: red">{$error}</p>
{/foreach}
{else}
<p class="bold">Your request was sended</p>
{/if}
{/if}
<form action="/modules/contactform/provider.php" method="post">
<label for="brand">{l s='brand' mod='contactform'}*</label>