Mean-field theory for Bose-Hubbard model under a magnetic field