Пример #1
0
$ref = GETPOST('ref', 'alpha');
$action = GETPOST('action', 'alpha');
// Security check
if ($user->societe_id) {
    $socid = $user->societe_id;
}
$result = restrictedArea($user, 'fournisseur', $id, '', 'commande');
$object = new CommandeFournisseur($db);
/*
 * Ajout d'un nouveau contact
 */
if ($action == 'addcontact' && $user->rights->fournisseur->commande->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");
            setEventMessage($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), 'errors');
        } else {
            setEventMessage($object->error, 'errors');
        }
    }
} else {
    if ($action == 'swapstatut' && $user->rights->fournisseur->commande->creer) {
        if ($object->fetch($id)) {
Пример #2
0
$langs->load("companies");
// Security check
$id = isset($_GET["id"]) ? $_GET["id"] : '';
if ($user->societe_id) {
    $socid = $user->societe_id;
}
$result = restrictedArea($user, 'commande_fournisseur', $id, '');
/*
 * Ajout d'un nouveau contact
 */
if ($_POST["action"] == 'addcontact' && $user->rights->fournisseur->commande->creer) {
    $result = 0;
    $commande = new CommandeFournisseur($db);
    $result = $commande->fetch($_GET["id"]);
    if ($result > 0 && $_GET["id"] > 0) {
        $result = $commande->add_contact($_POST["contactid"], $_POST["type"], $_POST["source"]);
    }
    if ($result >= 0) {
        Header("Location: contact.php?id=" . $commande->id);
        exit;
    } else {
        if ($commande->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
            $langs->load("errors");
            $mesg = '<div class="error">' . $langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType") . '</div>';
        } else {
            $mesg = '<div class="error">' . $commande->error . '</div>';
        }
    }
}
// modification d'un contact. On enregistre le type
if ($_POST["action"] == 'updateligne' && $user->rights->fournisseur->commande->creer) {