added email check
This commit is contained in:
parent
f36303a951
commit
17dccc2a6d
@ -217,7 +217,6 @@ if (empty($reshook) && $action == 'add') {
|
|||||||
$partnership->fk_soc = 0;
|
$partnership->fk_soc = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// need to change this part
|
|
||||||
$partnership->status = 0;
|
$partnership->status = 0;
|
||||||
$partnership->note_private = GETPOST('note_private');
|
$partnership->note_private = GETPOST('note_private');
|
||||||
$partnership->date_creation = dol_now();
|
$partnership->date_creation = dol_now();
|
||||||
@ -234,19 +233,22 @@ if (empty($reshook) && $action == 'add') {
|
|||||||
//$partnership->state_id = GETPOST('state_id', 'int');
|
//$partnership->state_id = GETPOST('state_id', 'int');
|
||||||
//$partnership->typeid = $conf->global->PARTNERSHIP_NEWFORM_FORCETYPE ? $conf->global->PARTNERSHIP_NEWFORM_FORCETYPE : GETPOST('typeid', 'int');
|
//$partnership->typeid = $conf->global->PARTNERSHIP_NEWFORM_FORCETYPE ? $conf->global->PARTNERSHIP_NEWFORM_FORCETYPE : GETPOST('typeid', 'int');
|
||||||
|
|
||||||
// Fill array 'array_options' with data from add form
|
|
||||||
$extrafields->fetch_name_optionals_label($partnership->table_element);
|
|
||||||
$ret = $extrafields->setOptionalsFromPost(null, $partnership);
|
|
||||||
if ($ret < 0) {
|
|
||||||
$error++;
|
|
||||||
}
|
|
||||||
// test if societe already exist
|
// test if societe already exist
|
||||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe WHERE nom='".$db->escape(GETPOST('societe'))."'";
|
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe WHERE nom='".$db->escape(GETPOST('societe'))."'";
|
||||||
$result = $db->query($sql);
|
$result = $db->query($sql);
|
||||||
if ($result) {
|
if ($result) {
|
||||||
$num = $db->num_rows($result);
|
$num = $db->num_rows($result);
|
||||||
}
|
}
|
||||||
if ($num = 0) {
|
if ($num = 0) { // si il ya pas d'entree sur le nom on teste l'email
|
||||||
|
$sql1 = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe WHERE email='".$db->escape(GETPOST('email'))."'";
|
||||||
|
$result1 = $db->query($sql1);
|
||||||
|
if ($result1) {
|
||||||
|
$num1 = $db->num_rows($result1);
|
||||||
|
}
|
||||||
|
if ($num1 != 0) {
|
||||||
|
$error++;
|
||||||
|
$errmsg = "email already exists please rewrite your company name";
|
||||||
|
} else {
|
||||||
//create thirdparty
|
//create thirdparty
|
||||||
$company = new Societe($db);
|
$company = new Societe($db);
|
||||||
|
|
||||||
@ -259,19 +261,28 @@ if (empty($reshook) && $action == 'add') {
|
|||||||
$company->name_alias = dolGetFirstLastname(GETPOST('firstname'), GETPOST('lastname'));
|
$company->name_alias = dolGetFirstLastname(GETPOST('firstname'), GETPOST('lastname'));
|
||||||
|
|
||||||
$resultat=$company->create($user);
|
$resultat=$company->create($user);
|
||||||
if ($result < 0) {
|
if ($resultat < 0) {
|
||||||
$error++;
|
$error++;
|
||||||
$errmsg .= join('<br>', $company->errors);
|
$errmsg .= join('<br>', $company->errors);
|
||||||
}
|
}
|
||||||
|
|
||||||
$partnership->fk_soc = $company->id;
|
$partnership->fk_soc = $company->id;
|
||||||
|
}
|
||||||
} elseif ($num > 1) {
|
} elseif ($num > 1) {
|
||||||
$error++;
|
$error++;
|
||||||
$errmsg = 'Message';
|
$errmsg = 'more than one entry exist for this company please contact us to complete your partnership request';
|
||||||
} else {
|
} else {
|
||||||
$company = $db->fetch_object($result);
|
$company = $db->fetch_object($result);
|
||||||
$partnership->fk_soc = $company->rowid;
|
$partnership->fk_soc = $company->rowid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fill array 'array_options' with data from add form
|
||||||
|
$extrafields->fetch_name_optionals_label($partnership->table_element);
|
||||||
|
$ret = $extrafields->setOptionalsFromPost(null, $partnership);
|
||||||
|
if ($ret < 0) {
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
|
||||||
if (!$error) {
|
if (!$error) {
|
||||||
$result = $partnership->create($user);
|
$result = $partnership->create($user);
|
||||||
if ($result > 0) {
|
if ($result > 0) {
|
||||||
@ -361,9 +372,6 @@ if (empty($reshook) && $action == 'add') {
|
|||||||
}
|
}
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (!empty($backtopage)) {
|
if (!empty($backtopage)) {
|
||||||
$urlback = $backtopage;
|
$urlback = $backtopage;
|
||||||
} elseif (!empty($conf->global->PARTNERSHIP_URL_REDIRECT_SUBSCRIPTION)) {
|
} elseif (!empty($conf->global->PARTNERSHIP_URL_REDIRECT_SUBSCRIPTION)) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user