header("Location: index.php"); exit; } } else { if ($action == 'update' && $user->rights->deplacement->creer) { if (!GETPOST('cancel', 'alpha')) { $result = $object->fetch($id); $object->date = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); $object->km = price2num(GETPOST('km', 'alpha'), 'MU'); // Not 'int', it may be a formated amount $object->type = GETPOST('type', 'alpha'); $object->socid = GETPOST('socid', 'int'); $object->fk_user = GETPOST('fk_user', 'int'); $object->note_private = GETPOST('note_private', 'alpha'); $object->note_public = GETPOST('note_public', 'alpha'); $result = $object->update($user); if ($result > 0) { header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id); exit; } else { setEventMessages($object->error, $object->errors, 'errors'); } } else { header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id); exit; } } else { if ($action == 'classin' && $user->rights->deplacement->creer) { $object->fetch($id); $result = $object->setProject(GETPOST('projectid', 'int')); if ($result < 0) {
if ($_POST["action"] == 'update' && $user->rights->deplacement->creer) { if (empty($_POST["cancel"])) { $deplacement = new Deplacement($db); $result = $deplacement->fetch($_POST["id"]); $deplacement->date = dol_mktime(12, 0 , 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); $deplacement->km = $_POST["km"]; $deplacement->type = $_POST["type"]; $deplacement->fk_user = $_POST["fk_user"]; $deplacement->socid = $_POST["socid"]; $result = $deplacement->update($user); if ($result > 0) { Header("Location: fiche.php?id=".$_POST["id"]); exit; } else { $mesg=$deplacement->error; } } else { Header("Location: ".$_SERVER["PHP_SELF"]."?id=".$_POST["id"]); exit;