$id = GETPOST('id', 'int');
$ref = GETPOST('ref', 'alpha');
// Security check
if ($user->societe_id) {
    $socid = $user->societe_id;
}
$result = restrictedArea($user, 'contrat', $id);
$object = new Contrat($db);
/*
 * Ajout d'un nouveau contact
 */
if ($action == 'addcontact' && $user->rights->contrat->creer) {
    $result = $object->fetch($id);
    if ($result > 0 && $id > 0) {
        $contactid = GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid');
        $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>';
        }
    }
}
// bascule du statut d'un contact
if ($action == 'swapstatut' && $user->rights->contrat->creer) {
Beispiel #2
0
$result = restrictedArea($user, 'contrat', $contratid);


/*
 * Ajout d'un nouveau contact
 */

if ($_POST["action"] == 'addcontact' && $user->rights->contrat->creer)
{
	$result = 0;
	$contrat = new Contrat($db);
	$result = $contrat->fetch($_GET["id"]);

    if ($result > 0 && $_POST["id"] > 0)
    {
  		$result = $contrat->add_contact($_POST["contactid"], $_POST["type"], $_POST["source"]);
    }

	if ($result >= 0)
	{
		Header("Location: contact.php?id=".$contrat->id);
		exit;
	}
	else
	{
		if ($contrat->error == 'DB_ERROR_RECORD_ALREADY_EXISTS')
		{
			$langs->load("errors");
			$mesg = '<div class="error">'.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'</div>';
		}
		else