thirdparty/contact creation seems ok

This commit is contained in:
Dorian Vabre 2021-04-26 14:28:37 +02:00
parent de63c93ad4
commit 1b4b93bc6a
2 changed files with 29 additions and 34 deletions

View File

@ -9156,6 +9156,7 @@ abstract class CommonObject
if ($c->fetch($add) > 0) { if ($c->fetch($add) > 0) {
$result = $c->add_type($this, $type_categ); $result = $c->add_type($this, $type_categ);
if ($result < 0) { if ($result < 0) {
var_dump($result);
$error++; $error++;
$this->error = $c->error; $this->error = $c->error;
$this->errors = $c->errors; $this->errors = $c->errors;
@ -9165,7 +9166,6 @@ abstract class CommonObject
} }
} }
} }
return $error ? -1 * $error : $ok; return $error ? -1 * $error : $ok;
} }

View File

@ -65,8 +65,9 @@ require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorbooth.class.php'; require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorbooth.class.php';
require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorboothattendee.class.php';
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/paymentterm.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/paymentterm.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
@ -270,8 +271,10 @@ if (empty($reshook) && $action == 'add') {
} }
} }
// From there we have a thirdparty, now looking for the contact // From there we have a thirdparty, now looking for the contact
if (!$error) {
$contact = new Contact($db); $contact = new Contact($db);
$resultcontact = $contact->fetch('', $user, '', $email); $resultcontact = $contact->fetch('', '', '', $email);
if ($resultcontact<=0) { if ($resultcontact<=0) {
// Need to create a contact // Need to create a contact
$contact->socid = $thirdparty->id; $contact->socid = $thirdparty->id;
@ -291,8 +294,9 @@ if (empty($reshook) && $action == 'add') {
$errmsg .= $contact->error; $errmsg .= $contact->error;
} }
} }
}
if (!$error) { // Only if we created the contact
if (!$error && $resultcontact<=0) {
// Adding supplier tag // Adding supplier tag
$category = new Categorie($db); $category = new Categorie($db);
if (GETPOST("suggestconference")) { if (GETPOST("suggestconference")) {
@ -307,9 +311,8 @@ if (empty($reshook) && $action == 'add') {
$error++; $error++;
$errmsg .= $category->error; $errmsg .= $category->error;
} else { } else {
$contact->setCategoriesCommon($category->id, Categorie::TYPE_CONTACT, false); $resultsetcategory = $contact->setCategoriesCommon(array($category->id), CATEGORIE::TYPE_CONTACT, false);
$resultupdate = $contact->update($contact->id); if ($resultsetcategory <=0) {
if ($resultupdate <= 0) {
$error++; $error++;
$errmsg .= $contact->error; $errmsg .= $contact->error;
} }
@ -454,16 +457,8 @@ if ($project->accept_booth_suggestions) {
print '<input type="submit" value="'.$langs->trans("SuggestBooth").'" name="suggestbooth" id="suggestbooth" class="button">'; print '<input type="submit" value="'.$langs->trans("SuggestBooth").'" name="suggestbooth" id="suggestbooth" class="button">';
} }
print '</div>'; print '</div>';
print '<br><br>'; print '<br><br>';
// Save
print '<div class="center">';
print '<input type="submit" value="'.$langs->trans("Submit").'" id="submitsave" class="button">';
if (!empty($backtopage)) {
print ' &nbsp; &nbsp; <input type="submit" value="'.$langs->trans("Cancel").'" id="submitcancel" class="button button-cancel">';
}
print '</div>';
print "</form>\n"; print "</form>\n";