DELIMITER $$
CREATE FUNCTION `addUser2` (
in_surname VARCHAR(255), in_name VARCHAR(255), in_midname VARCHAR(255),
in_login VARCHAR(64), in_password VARCHAR(255), in_headID INT(11), in_deputyID INT(11),
in_jid VARCHAR(255), in_sendNotify TINYINT(1), in_lock TINYINT(1), in_lockSelect TINYINT(1))
RETURNS INT(11)
BEGIN
DECLARE salt VARCHAR(32);
DECLARE passwd VARCHAR(32);
SET salt = MD5(UNIX_TIMESTAMP());
SET passwd = MD5(salt + password);
INSERT INTO
`users`
(`surname`, `name`, `midname`, `login`, `password`, `salt`, `headID`, `deputyID`, `jid`, `sendNotify`, `lock`, `lockSelect`)
VALUES
(in_surname, in_name, in_midname, in_login, passwd, salt, in_headID, in_deputyID, in_jid, in_sendNotify, in_lock, in_lockSelect);
RETURN LAST_INSERT_ID();
END