コード例 #1
0
ファイル: societecontact.php プロジェクト: ADDAdev/Dolibarr
$ref = GETPOST('ref', 'alpha');
$action = GETPOST('action', 'alpha');
// Security check
if ($user->societe_id) {
    $socid = $user->societe_id;
}
$result = restrictedArea($user, 'societe', $id, '');
$object = new Societe($db);
/*
 * Actions
 */
if ($action == 'addcontact' && $user->rights->societe->creer) {
    $result = $object->fetch($id);
    if ($result > 0 && $id > 0) {
        $contactid = GETPOST('userid', 'int') ? 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->societe->creer) {
        if ($object->fetch($id)) {