The problem is when you add user to company or project, user has already have rights to edit it and it gives database error since it tries to insert the same values twice. So, i added a control. If user try to add a user to a company or a consultant to a project that has already edit right, there will be a no problem anymore.
The other thing to mention is that, if you try to add a new user to a company but he/she has already a consultant to any project company is part of, it won't add him/her to the company user list since he/she has already right to edit company because he/she is already a consultant.
The problem is when you add user to company or project, user has already have rights to edit it and it gives database error since it tries to insert the same values twice. So, i added a control. If user try to add a user to a company or a consultant to a project that has already edit right, there will be a no problem anymore.
The other thing to mention is that, if you try to add a new user to a company but he/she has already a consultant to any project company is part of, it won't add him/her to the company user list since he/she has already right to edit company because he/she is already a consultant.