Topic: Can't Delete a company

I have been testing out Front Accounting and adding multiple companies in the process.
However, I can't delete any of these companies in the Create/Update company area.

It keeps giving me a message saying "Cannont remove company data directory ../company/5"  or 6 or whatever company number I am trying to delete.

Please let me know what I need to do to delete these extra companies without having to manually go into the database and remove the tables and directories that were created when setting up a new company.

Thanks,
Dave

Re: Can't Delete a company

Probably you are using old database on new source tree, where per company subtree is deleted on made unwritable for www server. The subdirectories should have sequential integer numbers beginning from 0 (this has nothing to do with database prefix!). So if you have 5 entries in db_connections (config_db.php) you should have 5 subdirectories from company/0 to company/4. After restoring check if all files have 777 access rights set then delete unneeded company in Create/Update Company page.
Janusz

Re: Can't Delete a company

I think the code uses rmdir, which should be replaced by a recursive delete. That fixed the problem in my case.

Re: Can't Delete a company

I'm getting that same error:

Broken company subdirectories system. You have to remove this company manually.

This is what my directory tree looks like with 4 companies:

root@hammer:/var/www/htdocs/fa/company# ls
0/  index.php*
root@hammer:/var/www/htdocs/fa/company# ls 0
backup/  images/  index.php*  installed_extensions.php  js_cache/  pdf_files/  reporting/
root@hammer:/var/www/htdocs/fa/company# ls -la  
total 16
drwxr-xr-x  3 root root 4096 Nov 27  2011 ./
drwxrwxrwx 23 root root 4096 Nov 28  2011 ../
drwxrwxrwx  7 root root 4096 Nov 28  2011 0/
-rwxrwxrwx  1 root root   43 Nov 24  2011 index.php*
root@hammer:/var/www/htdocs/fa/company# ls -la 0
total 36
drwxrwxrwx 7 root   root   4096 Nov 28  2011 ./
drwxr-xr-x 3 root   root   4096 Nov 27  2011 ../
drwxrwxrwx 2 root   root   4096 Nov 28  2011 backup/
drwxrwxrwx 2 root   root   4096 Nov 28  2011 images/
-rwxrwxrwx 1 root   root     43 Nov 24  2011 index.php*
-rw-r--r-- 1 apache apache  147 Nov 28  2011 installed_extensions.php
drwxrwxrwx 2 root   root   4096 Jun 10 00:05 js_cache/
drwxrwxrwx 2 root   root   4096 Nov 28  2011 pdf_files/
drwxrwxrwx 2 root   root   4096 Nov 27  2011 reporting/

I only see one directory there, and I'm running FrontAccounting 2.3.9.

Shouldn't there be a company/1, company/2, and company/3 directory?

What's the next thing to look at for manually removing a company?

Thanks smile

Re: Can't Delete a company

Nothing has changed in this matter so far, answer to your question you can find in second post in this thread.
Janusz

6 (edited by tallship 06/22/2012 04:32:19 am)

Re: Can't Delete a company

itronics wrote:

Nothing has changed in this matter so far, answer to your question you can find in second post in this thread.
Janusz

Okay I saw that there was one file there that wasn't chmod'd 777:

-rw-r--r-- 1 apache apache  147 Nov 28  2011 installed_extensions.php

So I set it 777. When that didn't work I:

root@hammer:/var/www/htdocs/fa/company# chmod -Rv 777 .

And I still got the same error when trying to remove a company.

So finally I set everything from the DocumentRoot of the FA installation (/var/www/htdocs/fa) on down as 777 and still I'm receiving the same error.

Everything in the entire FA installation, all directories and files, to 777

What should I look at trying next?

Thanks )

Re: Can't Delete a company

Well, this is quite simple: if you have 3 companies in your config_db.php fiel, you should have 3 private folders under company, named '0' to '2'. If for some reason anyone subfolder is missing the company deletion fails. This is because folders have to renumbered  when you delete any but the last one company (e.g. removing company 1 will require renaming the '2' folder to '1'). This cannot be done when some folder is missing.

Janusz

Re: Can't Delete a company

Thanks Janusz!

I did a:

# pwd
/var/www/fa/company
# mkdir -p 1 2 3
# chmod -Rv 777 *

Then logged into FA as admin and deleted company 2 and 3 no problem. Company 4 is now effectively company 2 using the /var/www/htdocs/fa/company/1 directory.

That did the trick. Of interesting note is that what was previously company 4, which had the table prefix 3_, still has the same prefix (Like you said it has nothing to do with the ...fa/company/ directory tree naming scheme), and after deleting company 2 and company 3 it still retains the same table prefix, which I believe is what you were trying to explain in another post above.

Once again,

Thanks smile

Re: Can't Delete a company

Yes, this is exactly how it works. Directory name is  not database prefix but company index in $db_connections table.
Janusz

10 (edited by hfinger 03/13/2014 02:25:21 am)

Re: Can't Delete a company

Broken company subdirectories system. You have to remove this company manually.

I stupidly deleted a company database from MySQL with phpAdmin. Not surprisingly, FA wouldn't delete the company. Then I deleted the .../company/1/ folder. Again, no go.

How do I now delete the company manually?

Re: Can't Delete a company

You should also remove it from the file, config_db.php. Be careful, however, to delete the right things.

/Joe

Re: Can't Delete a company

Notes:

The php function rmdir can be used only if the directory is empty.

When safe mode is enabled, PHP checks whether the directory in which the script is operating has the same UID (owner) as the script that is being executed.