Multi Company


Update 13 Jan 2006
The work described below was coded and released with version 3.02 - in Sept 2005

EDO - Nicholas Gerber and Mo Mobarak contributed a substantial amount of development work undertaken by ITWorx. This contribution allowed for setting up a service based business renting hosted webERP to businesses wishing to do their accounting from anywhere free from the worry of backup and hosting a complex ERP application themselves.

Central to this business model is the requirement to allow multiple companies to be set up using the same scripts but with different databases. A self signup form allows for the user to create a new webERP installation with a separate database. If felt this concept to be a really good one and something that webERP should have as native functionality.

webERP requires for each company:

1. A separate DB
2. Separate directory for part pictures
3. Its own logo.jpg

A separate directory makes sense then to be the base of this information. A "companies" sub-directory holding further sub-directories for each company installation. This sub-directory holding the logo.jpg, the part_pics sub-directory and the various EDI directories.

However, the EDO work requires a new database user and password to be defined and I didn't see why this was necessary. User names and passwords are defined for all users in each database - all that is really required is to enter the database name (or company) and enter a user name and password to get access to that company that is specifically defined for the user logging in.

What is required is a form to allow entry of a company abbreviation in a format that is suitable for a database name - and checked as such then to:

1. Create a directory for this company under the companies sub-directory
2. Create a new database of this name and run the new company install script from the sql/mysql/weberp_new.sql or sql/pg/weberp_new.psql depending on whether the perference is postgres or mysql.
3. Upload a logo to the companies/{companyname}/logo.jpg
4. Ensure that part pictures are stored in a user named directory under this sub-directory

The EDO allowed the user to enter the company details as part of this signup, under the scenario I propose this would be done in the usual CompanyPreferences.php page that the user would be linked to after creation of the DB above.

The login.php script would now require a user to also enter their company abbreviation (which is the database name to connect to). The existing config.php where the DB connection parameters are held will no longer require the $DatabaseName value to be set as this will be passed with the logon and held as a session variable for subsequent calls to system scripts.

Unfortunately, I couldn't find the scripts for the creation of a new company - so I made one up of my own as a Z script Z_MakeNewCompany.php - but stealing much of the ideas of Mo and ITWorx - thanks guys.

The logo on the login screen - which does not know which company is logging in is now an image called logo_server.jpg. The company logo is now under companies/{Company Name/DB Name}/logo.jpg and is uploaded at the time of creating a new company using the above script.



BrainX: Pretty good, i think we could make better the "login"... I think in making a "list" in the config.php and display a dropbox on the login screen. What do you think about?

Phil: Yes I thought about this ... I thought we could make a dir of all the files(directories) under ./companies and make a combo box as we do for languages in the UserSettings.php script. However, security wise it would be better for the user to explicitly specify the company name, user name and password combination that gets them in. Also, in a hosted environment ... where the people who wanted this multi-company stuff enough to pay ITWorx to develop it operate, they host many businesses accounting and it may not be acceptable to disclose the other companies that are also hosted in a drop box.

Valid XHTML :: Valid CSS: :: Powered by WikkaWikiGet webERP Accounting & Business Management at SourceForge.net. Fast, secure and Free Open Source software downloads