/* * Ajout d'un nouveau contact */ if ($_POST["action"] == 'addcontact' && $user->rights->commande->creer) { $result = 0; $commande = new Commande($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
$ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'alpha'); // Security check if ($user->societe_id) { $socid = $user->societe_id; } $result = restrictedArea($user, 'commande', $id, ''); $object = new Commande($db); /* * Ajout d'un nouveau contact */ if ($action == 'addcontact' && $user->rights->commande->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"); setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors'); } else { setEventMessages($object->error, $object->errors, 'errors'); } } } else { if ($action == 'swapstatut' && $user->rights->commande->creer) { if ($object->fetch($id)) {