$socid = GETPOST('socid', 'int'); $action = GETPOST('action', 'alpha'); // Security check if ($user->societe_id) { $socid = $user->societe_id; } $result = restrictedArea($user, 'facture', $id); $object = new Facture($db); /* * Ajout d'un nouveau contact */ if ($action == 'addcontact' && $user->rights->facture->creer) { $result = $object->fetch($id); if ($result > 0 && $id > 0) { $contactid = GETPOST('userid') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int'); $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); } if ($result >= 0) { Header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $object->id); exit; } else { if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { $langs->load("errors"); $mesg = '<div class="error">' . $langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType") . '</div>'; } else { $mesg = '<div class="error">' . $object->error . '</div>'; } } } else { if ($action == 'swapstatut' && $user->rights->facture->creer) { if ($object->fetch($id)) {
/* * Ajout d'un nouveau contact */ if ($_POST["action"] == 'addcontact' && $user->rights->facture->creer) { $result = 0; $facture = new Facture($db); $result = $facture->fetch($_GET["facid"]); if ($result > 0 && $_GET["facid"] > 0) { $result = $facture->add_contact($_POST["contactid"], $_POST["type"], $_POST["source"]); } if ($result >= 0) { Header("Location: contact.php?facid=".$facture->id); exit; } else { if ($facture->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { $langs->load("errors"); $mesg = '<div class="error">'.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'</div>'; } else