1 #=====================================================================
4 # Based on SQL-Ledger Version 2.1.9
5 # Web http://www.lx-office.org
7 #=====================================================================
8 # SQL-Ledger Accounting
11 # Author: Dieter Simader
12 # Email: dsimader@sql-ledger.org
13 # Web: http://www.sql-ledger.org
16 # This program is free software; you can redistribute it and/or modify
17 # it under the terms of the GNU General Public License as published by
18 # the Free Software Foundation; either version 2 of the License, or
19 # (at your option) any later version.
21 # This program is distributed in the hope that it will be useful,
22 # but WITHOUT ANY WARRANTY; without even the implied warranty of
23 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 # GNU General Public License for more details.
25 # You should have received a copy of the GNU General Public License
26 # along with this program; if not, write to the Free Software
27 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 #======================================================================
31 # add/edit/delete users
33 #======================================================================
35 $menufile = "menu.ini";
43 $locale = new Locale $language, "admin";
45 eval { require DBI; };
46 $form->error($locale->text('DBI not installed!')) if ($@);
50 if (-f "$form->{path}/custom_$form->{script}") {
51 eval { require "$form->{path}/custom_$form->{script}"; };
52 $form->error($@) if ($@);
56 $form->{stylesheet} = "lx-office-erp.css";
57 $form->{favicon} = "favicon.ico";
59 if ($form->{action}) {
61 $subroutine = $locale->findsub($form->{action});
63 if ($subroutine eq 'login') {
65 $form->{rpw} = crypt $form->{rpw}, "ro";
75 # if there are no drivers bail out
76 $form->error($locale->text('No Database Drivers available!')) unless (User->dbdrivers);
79 if (! -f $memberfile) {
80 open(FH, ">$memberfile") or $form->error("$memberfile : $!");
81 print FH qq|# SQL-Ledger Accounting members
100 $form->{title} = qq|Lx-Office ERP $form->{version} |.$locale->text('Administration');
110 <a href="http://www.lx-office.org"><img src="image/lx-office-erp.png" border=0></a>
111 <h1 class=login>|.$locale->text('Version').qq| $form->{version}<p>|.$locale->text('Administration').qq|</h1>
113 <form method=post action="$form->{script}">
117 <th>|.$locale->text('Password').qq|</th>
118 <td><input type=password name=rpw></td>
119 <td><input type=submit class=submit name=action value="|.$locale->text('Login').qq|"></td>
121 <input type=hidden name=action value=login>
122 <input type=hidden name=root value="root login">
123 <input type=hidden name=path value=$form->{path}>
129 <a href=http://www.lx-office.org>Lx-Office |.$locale->text('website').qq|</a>
152 $form->{title} = "Lx-Office ERP ".$locale->text('Administration')." / ".$locale->text('Add User');
154 $form->{Oracle_sid} = $sid;
155 $form->{Oracle_dbport} = '1521';
156 $form->{Oracle_dbhost} = `hostname`;
158 if (-f "css/lx-office-erp.css") {
159 $myconfig->{stylesheet} = "lx-office-erp.css";
161 $myconfig->{vclimit} = 200;
172 $form->{title} = "Lx-Office ERP ".$locale->text('Administration')." / ".$locale->text('Edit User');
184 $delete = qq|<input type=submit class=submit name=action value="|.$locale->text('Delete').qq|">
185 <input type=hidden name=edit value=1>|;
190 <input name=callback type=hidden value="$form->{script}?action=list_users&path=$form->{path}&root=$form->{root}&rpw=$form->{rpw}">
191 <input type=hidden name=root value="$form->{root}">
192 <input type=hidden name=path value=$form->{path}>
193 <input type=hidden name=rpw value=$form->{rpw}>
195 <input type=submit class=submit name=action value="|.$locale->text('Save').qq|">
209 $form->error($locale->text('File locked!')) if (-f "${memberfile}.LCK");
211 open(FH, "$memberfile") or $form->error("$memberfile : $!");
214 <input type=submit class=submit name=action value="|.$locale->text('Lock System').qq|">|;
216 if (-e "$userspath/nologin") {
218 <input type=submit class=submit name=action value="|.$locale->text('Unlock System').qq|">|;
227 $login =~ s/(\[|\])//g;
230 if (/^(name=|company=|templates=|dbuser=|dbdriver=|dbname=|dbhost=)/) {
232 ($null, $member{$login}{$var}) = split /=/, $_, 2;
238 # type=submit $locale->text('Pg Database Administration')
239 # type=submit $locale->text('Oracle Database Administration')
241 foreach $item (User->dbdrivers) {
242 $dbdrivers .= qq|<input name=action type=submit class=submit value="|.$locale->text("$item Database Administration").qq|">|;
246 $column_header{login} = qq|<th>|.$locale->text('Login').qq|</th>|;
247 $column_header{name} = qq|<th>|.$locale->text('Name').qq|</th>|;
248 $column_header{company} = qq|<th>|.$locale->text('Company').qq|</th>|;
249 $column_header{dbdriver} = qq|<th>|.$locale->text('Driver').qq|</th>|;
250 $column_header{dbhost} = qq|<th>|.$locale->text('Host').qq|</th>|;
251 $column_header{dataset} = qq|<th>|.$locale->text('Dataset').qq|</th>|;
252 $column_header{templates} = qq|<th>|.$locale->text('Templates').qq|</th>|;
254 @column_index = qw(login name company dbdriver dbhost dataset templates);
256 $form->{title} = "Lx-Office ERP ".$locale->text('Administration');
263 <form method=post action=$form->{script}>
267 <tr class=listheading>
268 <th>$form->{title}</th>
274 <tr class=listheading>|;
276 map { print "$column_header{$_}\n" } @column_index;
282 foreach $key (sort keys %member) {
283 $href = "$script?action=edit&login=$key&path=$form->{path}&root=$form->{root}&rpw=$form->{rpw}";
286 $member{$key}{templates} =~ s/^$templates\///;
287 $member{$key}{dbhost} = $locale->text('localhost') unless $member{$key}{dbhost};
288 $member{$key}{dbname} = $member{$key}{dbuser} if ($member{$key}{dbdriver} eq 'Oracle');
290 $column_data{login} = qq|<td><a href=$href>$key</a></td>|;
291 $column_data{name} = qq|<td>$member{$key}{name}</td>|;
292 $column_data{company} = qq|<td>$member{$key}{company}</td>|;
293 $column_data{dbdriver} = qq|<td>$member{$key}{dbdriver}</td>|;
294 $column_data{dbhost} = qq|<td>$member{$key}{dbhost}</td>|;
295 $column_data{dataset} = qq|<td>$member{$key}{dbname}</td>|;
296 $column_data{templates} = qq|<td>$member{$key}{templates}</td>|;
300 <tr class=listrow$i>|;
302 map { print "$column_data{$_}\n" } @column_index;
314 <td><hr size=3 noshade></td>
318 <input type=hidden name=path value=$form->{path}>
319 <input type=hidden name=rpw value=$form->{rpw}>
320 <input type=hidden name=root value="$form->{root}">
322 <br><input type=submit class=submit name=action value="|.$locale->text('Add User').qq|">
323 <input type=submit class=submit name=action value="|.$locale->text('Change Admin Password').qq|">
330 |.$locale->text('Click on login name to edit!').qq|
332 |.$locale->text('To add a user to a group edit a name, change the login name and save. A new user with the same variables will then be saved under the new login name.').qq|
336 <form method=post action=login.pl>
338 <table border=0 width=100%>
339 <tr class=listheading>
340 <th>Lx-Office ERP |.$locale->text('Login').qq|</th>
346 <th align=right>|.$locale->text('Name').qq|</th>
347 <td><input class=login name=login></td>
351 <th align=right>|.$locale->text('Password').qq|</th>
352 <td><input class=login type=password name=password></td>
353 <td><input type=submit name=action value="|.$locale->text('Login').qq|"></td>
355 <input type=hidden name=path value=$form->{path}>
375 # if there is a login, get user
376 if ($form->{login}) {
378 $myconfig = new User "$memberfile", "$form->{login}";
380 $myconfig->{signature} =~ s/\\n/\r\n/g;
381 $myconfig->{address} =~ s/\\n/\r\n/g;
383 # strip basedir from templates directory
384 $myconfig->{templates} =~ s/^$templates\///;
386 # $myconfig->{dbpasswd} = unpack 'u', $myconfig->{dbpasswd};
390 foreach $item (qw(mm-dd-yy mm/dd/yy dd-mm-yy dd/mm/yy dd.mm.yy yyyy-mm-dd)) {
391 $dateformat .= ($item eq $myconfig->{dateformat}) ? "<option selected>$item\n" : "<option>$item\n";
394 foreach $item (qw(1,000.00 1000.00 1.000,00 1000,00)) {
395 $numberformat .= ($item eq $myconfig->{numberformat}) ? "<option selected>$item\n" : "<option>$item\n";
399 %countrycodes = User->country_codes;
401 foreach $key (sort { $countrycodes{$a} cmp $countrycodes{$b} } keys %countrycodes) {
402 $countrycodes .= ($myconfig->{countrycode} eq $key) ? "<option selected value=$key>$countrycodes{$key}" : "<option value=$key>$countrycodes{$key}";
404 $countrycodes = qq|<option value="">American English\n$countrycodes|;
406 # is there a templates basedir
407 if (! -d "$templates") {
408 $form->error($locale->text('Directory').": $templates ".$locale->text('does not exist'));
411 opendir TEMPLATEDIR, "$templates/." or $form->error("$templates : $!");
412 @all = grep !/^\.\.?$/, readdir TEMPLATEDIR;
413 closedir TEMPLATEDIR;
415 @allhtml = sort grep /\.html/, @all;
416 @alldir = grep !/\.(html|tex)$/, @all;
418 @allhtml = reverse grep !/Default/, @allhtml;
419 push @allhtml, 'Default';
420 @allhtml = reverse @allhtml;
422 foreach $item (@alldir) {
423 if ($item eq $myconfig->{templates}) {
424 $usetemplates .= qq|<option selected>$item\n|;
426 $usetemplates .= qq|<option>$item\n|;
430 $lastitem = $allhtml[0];
431 $lastitem =~ s/-.*//g;
432 $mastertemplates = qq|<option>$lastitem\n|;
433 foreach $item (@allhtml) {
436 if ($item ne $lastitem) {
437 $mastertemplates .= qq|<option>$item\n|;
442 opendir CSS, "css/.";
443 @all = grep /.*\.css$/, readdir CSS;
446 foreach $item (@all) {
447 if ($item eq $myconfig->{stylesheet}) {
448 $selectstylesheet .= qq|<option selected>$item\n|;
450 $selectstylesheet .= qq|<option>$item\n|;
453 $selectstylesheet .= "<option>\n";
461 <form method=post action=$form->{script}>
464 <tr class=listheading><th colspan=2>$form->{title}</th></tr>
470 <th align=right>|.$locale->text('Login').qq|</th>
471 <td><input name=login value="$myconfig->{login}"></td>
474 <th align=right>|.$locale->text('Password').qq|</th>
475 <td><input type=password name=password size=8 value=$myconfig->{password}></td>
476 <input type=hidden name=old_password value=$myconfig->{password}>
479 <th align=right>|.$locale->text('Name').qq|</th>
480 <td><input name=name size=15 value="$myconfig->{name}"></td>
483 <th align=right>|.$locale->text('E-mail').qq|</th>
484 <td><input name=email size=30 value="$myconfig->{email}"></td>
487 <th align=right>|.$locale->text('Signature').qq|</th>
488 <td><textarea name=signature rows=3 cols=35>$myconfig->{signature}</textarea></td>
491 <th align=right>|.$locale->text('Phone').qq|</th>
492 <td><input name=tel size=14 value="$myconfig->{tel}"></td>
495 <th align=right>|.$locale->text('Fax').qq|</th>
496 <td><input name=fax size=14 value="$myconfig->{fax}"></td>
499 <th align=right>|.$locale->text('Company').qq|</th>
500 <td><input name=company size=35 value="$myconfig->{company}"></td>
503 <th align=right>|.$locale->text('Address').qq|</th>
504 <td><textarea name=address rows=4 cols=35>$myconfig->{address}</textarea></td>
507 <th align=right>|.$locale->text('Steuernummer').qq|</th>
508 <td><input name=steuernummer size=14 value="$myconfig->{steuernummer}"></td>
511 <th align=right>|.$locale->text('Ust-IDNr').qq|</th>
512 <td><input name=ustid size=14 value="$myconfig->{ustid}"></td>
515 <th align=right>|.$locale->text('DUNS-Nr').qq|</th>
516 <td><input name=duns size=14 value="$myconfig->{duns}"></td>
523 <th align=right>|.$locale->text('Date Format').qq|</th>
524 <td><select name=dateformat>$dateformat</select></td>
527 <th align=right>|.$locale->text('Number Format').qq|</th>
528 <td><select name=numberformat>$numberformat</select></td>
531 <th align=right>|.$locale->text('Dropdown Limit').qq|</th>
532 <td><input name=vclimit value="$myconfig->{vclimit}"></td>
535 <th align=right>|.$locale->text('Language').qq|</th>
536 <td><select name=countrycode>$countrycodes</select></td>
539 <th align=right>|.$locale->text('Character Set').qq|</th>
540 <td><input name=charset value="$myconfig->{charset}"></td>
543 <th align=right>|.$locale->text('Stylesheet').qq|</th>
544 <td><select name=userstylesheet>$selectstylesheet</select></td>
547 <th align=right>|.$locale->text('Printer').qq|</th>
548 <td><input name=printer size=20 value="$myconfig->{printer}"></td>
551 <th align=right>|.$locale->text('Use Templates').qq|</th>
552 <td><select name=usetemplates>$usetemplates</select></td>
555 <th align=right>|.$locale->text('New Templates').qq|</th>
556 <td><input name=newtemplates></td>
559 <th align=right>|.$locale->text('Setup Templates').qq|</th>
560 <td><select name=mastertemplates>$mastertemplates</select></td>
562 <input type=hidden name=templates value=$myconfig->{templates}>
566 <tr class=listheading>
567 <th colspan=2>|.$locale->text('Database').qq|</th>
570 # list section for database drivers
571 foreach $item (User->dbdrivers) {
580 if ($myconfig->{dbdriver} eq $item) {
581 map { $form->{"${item}_$_"} = $myconfig->{$_} } qw(dbhost dbport dbuser dbpasswd dbname sid);
582 $checked = "checked";
586 <th align=right>|.$locale->text('Driver').qq|</th>
587 <td><input name=dbdriver type=radio class=radio value=$item $checked> $item</td>
588 <th align=right>|.$locale->text('Host').qq|</th>
589 <td><input name="${item}_dbhost" size=30 value=$form->{"${item}_dbhost"}></td>
595 <th align=right>|.$locale->text('Dataset').qq|</th>
596 <td><input name=Pg_dbname size=15 value=$form->{Pg_dbname}></td>
597 <th align=right>|.$locale->text('Port').qq|</th>
598 <td><input name=Pg_dbport size=4 value=$form->{Pg_dbport}></td>
601 <th align=right>|.$locale->text('User').qq|</th>
602 <td><input name="${item}_dbuser" size=15 value=$form->{"${item}_dbuser"}></td>
603 <th align=right>|.$locale->text('Password').qq|</th>
604 <td><input name="${item}_dbpasswd" type=password size=10 value=$form->{"${item}_dbpasswd"}></td>
609 if ($item eq 'Oracle') {
611 <th align=right>SID</th>
612 <td><input name=Oracle_sid value=$form->{Oracle_sid}></td>
613 <th align=right>|.$locale->text('Port').qq|</th>
614 <td><input name=Oracle_dbport size=4 value=$form->{Oracle_dbport}></td>
617 <th align=right>|.$locale->text('Dataset').qq|</th>
618 <td><input name="${item}_dbuser" size=15 value=$form->{"${item}_dbuser"}></td>
619 <th align=right>|.$locale->text('Password').qq|</th>
620 <td><input name="${item}_dbpasswd" type=password size=10 value=$form->{"${item}_dbpasswd"}></td>
627 <input type=hidden name=old_dbpasswd value=$myconfig->{dbpasswd}>
632 <td colspan=2><hr size=2 noshade></td>
640 open(FH, $menufile) or $form->error("$menufile : $!");
641 # scan for first menu level
645 if (open(FH, "custom_$menufile")) {
651 next unless $item =~ /\[/;
652 next if $item =~ /\#/;
654 $item =~ s/(\[|\])//g;
658 ($level, $menuitem) = split /--/, $item, 2;
662 push @acsorder, $item;
665 push @{ $acs{$level} }, $menuitem;
669 %role = ( 'admin' => $locale->text('Administrator'),
670 'user' => $locale->text('User'),
671 'manager' => $locale->text('Manager'),
672 'supervisor' => $locale->text('Supervisor')
676 foreach $item (qw(user supervisor manager admin)) {
677 $selectrole .= ($myconfig->{role} eq $item) ? "<option selected value=$item>$role{$item}\n" : "<option value=$item>$role{$item}\n";
681 <tr class=listheading>
682 <th colspan=2>|.$locale->text('Access Control').qq|</th>
685 <td><select name=role>$selectrole</select></td>
689 foreach $item (split /;/, $myconfig->{acs}) {
690 ($key, $value) = split /--/, $item, 2;
691 $excl{$key}{$value} = 1;
694 foreach $key (@acsorder) {
696 $checked = "checked";
697 if ($form->{login}) {
698 $checked = ($excl{$key}{$key}) ? "" : "checked";
701 # can't have variable names with spaces
702 # the 1 is for apache 2
703 $item = $form->escape("${key}--$key", 1);
706 $acsheading =~ s/ / /g;
709 <th align=left><input name="$item" class=checkbox type=checkbox value=1 $checked> $acsheading</th>\n|;
710 $menuitems .= "$item;";
714 foreach $item (@{ $acs{$key} }) {
715 next if ($key eq $item);
717 $checked = "checked";
718 if ($form->{login}) {
719 $checked = ($excl{$key}{$item}) ? "" : "checked";
722 $acsitem = $form->escape("${key}--$item", 1);
725 <br><input name="$acsitem" class=checkbox type=checkbox value=1 $checked> $item|;
726 $menuitems .= "$acsitem;";
733 <tr valign=top>$acsheading $acsdata
738 print qq|<input type=hidden name=acs value="$menuitems">
741 @webdavdirs = qw(angebote bestellungen rechnungen anfragen lieferantenbestellungen einkaufsrechnungen);
742 foreach $directory (@webdavdirs) {
743 if ($myconfig->{$directory}) {
744 $webdav{"${directory}c"} = "checked";
746 $webdav{"${directory}c"} = "";
751 <td colspan=2><hr size=3 noshade></td>
753 <tr class=listheading>
754 <th colspan=2>|.$locale->text('WEBDAV-Zugriff').qq|</th>
758 <td><input name=angebote class=checkbox type=checkbox value=1 $webdav{angebotec}> Angebot</td>
759 <td><input name=bestellungen class=checkbox type=checkbox value=1 $webdav{bestellungenc}> Bestellung</td>
760 <td><input name=rechnungen class=checkbox type=checkbox value=1 $webdav{rechnungenc}> Rechnung</td>
763 <td><input name=anfragen class=checkbox type=checkbox value=1 $webdav{anfragenc}> Angebot</td>
764 <td><input name=lieferantenbestellungen class=checkbox type=checkbox value=1 $webdav{lieferantenbestellungenc}> Lieferantenbestellung</td>
765 <td><input name=einkaufsrechnungen class=checkbox type=checkbox value=1 $webdav{einkaufsrechnungenc}> Einkaufsrechnung</td>
769 <td colspan=2><hr size=3 noshade></td>
784 $form->error($locale->text('Database Driver not checked!')) unless $form->{dbdriver};
786 # no spaces allowed in login name
787 ($form->{login}) = split / /, $form->{login};
789 $form->isblank("login", $locale->text('Login name missing!'));
791 # check for duplicates
792 if (!$form->{edit}) {
793 $temp = new User "$memberfile", "$form->{login}";
795 if ($temp->{login}) {
796 $form->error("$form->{login} ".$locale->text('is already a member!'));
800 # no spaces allowed in directories
801 ($form->{newtemplates}) = split / /, $form->{newtemplates};
803 if ($form->{newtemplates}) {
804 $form->{templates} = $form->{newtemplates};
806 $form->{templates} = ($form->{usetemplates}) ? $form->{usetemplates} : $form->{login};
810 if (! -d "$templates") {
811 $form->error($locale->text('Directory').": $templates ".$locale->text('does not exist'));
814 # add base directory to $form->{templates}
815 $form->{templates} = "$templates/$form->{templates}";
818 $myconfig = new User "$memberfile", "$form->{login}";
820 # redo acs variable and delete all the acs codes
821 @acs = split /;/, $form->{acs};
824 foreach $item (@acs) {
825 $item = $form->escape($item, 1);
827 if (!$form->{$item}) {
828 $form->{acs} .= $form->unescape($form->unescape($item)).";";
830 delete $form->{$item};
833 # check which database was filled in
834 if ($form->{dbdriver} eq 'Oracle') {
835 $form->{sid} = $form->{Oracle_sid}, ;
836 $form->{dbhost} = $form->{Oracle_dbhost}, ;
837 $form->{dbport} = $form->{Oracle_dbport};
838 $form->{dbpasswd} = $form->{Oracle_dbpasswd};
839 $form->{dbuser} = $form->{Oracle_dbuser};
840 $form->{dbname} = $form->{Oracle_dbuser};
842 $form->isblank("dbhost", $locale->text('Hostname missing!'));
843 $form->isblank("dbport", $locale->text('Port missing!'));
844 $form->isblank("dbuser", $locale->text('Dataset missing!'));
846 if ($form->{dbdriver} eq 'Pg') {
847 $form->{dbhost} = $form->{Pg_dbhost};
848 $form->{dbport} = $form->{Pg_dbport};
849 $form->{dbpasswd} = $form->{Pg_dbpasswd};
850 $form->{dbuser} = $form->{Pg_dbuser};
851 $form->{dbname} = $form->{Pg_dbname};
853 $form->isblank("dbname", $locale->text('Dataset missing!'));
854 $form->isblank("dbuser", $locale->text('Database User missing!'));
858 @webdavdirs = qw(angebote bestellungen rechnungen anfragen lieferantenbestellungen einkaufsrechnungen);
859 foreach $directory (@webdavdirs) {
860 if ($form->{$directory}) {
861 $form->{$directory} = $form->{$directory};
863 $form->{$directory} = 0;
868 foreach $item (keys %{$form}) {
869 $myconfig->{$item} = $form->{$item};
872 delete $myconfig->{stylesheet};
873 if ($form->{userstylesheet}) {
874 $myconfig->{stylesheet} = $form->{userstylesheet};
877 $myconfig->save_member($memberfile, $userspath);
880 @webdavdirs = qw(angebote bestellungen rechnungen anfragen lieferantenbestellungen einkaufsrechnungen);
881 foreach $directory (@webdavdirs) {
882 $file = "webdav/".$directory."/webdav-user";
883 if ($form->{$directory}) {
884 if (open (HTACCESS, "$file")) {
886 ($login,$password) = split(/:/, $_);
887 if ($login ne $form->{login}) {
893 open (HTACCESS, "> $file") or die "cannot open $file $!\n";
894 $newfile .= $myconfig->{login}.":".$myconfig->{password}."\n";
895 print (HTACCESS $newfile);
898 $form->{$directory} = 0;
899 if (open (HTACCESS, "$file")) {
901 ($login,$password) = split(/:/, $_);
902 if ($login ne $form->{login}) {
908 open (HTACCESS, "> $file") or die "cannot open $file $!\n";
909 print (HTACCESS $newfile);
915 # create user template directory and copy master files
916 if (! -d "$form->{templates}") {
919 if (mkdir "$form->{templates}", oct("771")) {
923 # copy templates to the directory
924 opendir TEMPLATEDIR, "$templates/." or $form-error("$templates : $!");
925 @templates = grep /$form->{mastertemplates}.*?\.(html|tex)$/, readdir TEMPLATEDIR;
926 closedir TEMPLATEDIR;
928 foreach $file (@templates) {
929 open(TEMP, "$templates/$file") or $form->error("$templates/$file : $!");
931 $file =~ s/$form->{mastertemplates}-//;
932 open(NEW, ">$form->{templates}/$file") or $form->error("$form->{templates}/$file : $!");
934 while ($line = <TEMP>) {
941 $form->error("$!: $form->{templates}");
947 $form->redirect($locale->text('User saved!'));
954 $form->{templates} = ($form->{templates}) ? "$templates/$form->{templates}" : "$templates/$form->{login}";
956 $form->error($locale->text('File locked!')) if (-f ${memberfile}.LCK);
957 open(FH, ">${memberfile}.LCK") or $form->error("${memberfile}.LCK : $!");
960 open(CONF, "+<$memberfile") or $form->error("$memberfile : $!");
967 while ($line = shift @config) {
969 if ($line =~ /^\[/) {
970 last if ($line =~ /\[$form->{login}\]/);
971 $login = &login_name($line);
974 if ($line =~ /^templates=/) {
975 $user{$login} = &get_value($line);
981 # remove everything up to next login or EOF
982 # and save template variable
983 while ($line = shift @config) {
984 if ($line =~ /^templates=/) {
985 $templatedir = &get_value($line);
987 last if ($line =~ /^\[/);
990 # this one is either the next login or EOF
993 $login = &login_name($line);
996 while ($line = shift @config) {
997 if ($line =~ /^\[/) {
998 $login = &login_name($line);
1001 if ($line =~ /^templates=/) {
1002 $user{$login} = &get_value($line);
1009 unlink "${memberfile}.LCK";
1011 # scan %user for $templatedir
1012 foreach $login (keys %user) {
1013 last if ($found = ($templatedir eq $user{$login}));
1016 # if found keep directory otherwise delete
1018 # delete it if there is a template directory
1019 $dir = "$form->{templates}";
1021 unlink <$dir/*.html>;
1022 unlink <$dir/*.tex>;
1027 # delete config file for user
1028 unlink "$userspath/$form->{login}.conf";
1030 $form->redirect($locale->text('User deleted!'));
1038 $login =~ s/\[\]//g;
1039 return ($login) ? $login : undef;
1048 my ($null, $value) = split(/=/, $line, 2);
1051 $value =~ s/\s#.*//g;
1053 # remove any trailing whitespace
1054 $value =~ s/^\s*(.*?)\s*$/$1/;
1061 sub change_admin_password {
1063 $form->{title} = qq|Lx-Office ERP |.$locale->text('Administration')." / ".$locale->text('Change Admin Password');
1071 <h2>|.$locale->text('Change Admin Password').qq|</h2>
1073 <form method=post action=$form->{script}>
1075 <b>|.$locale->text('Password').qq|</b> <input type=password name=password size=8>
1077 <input type=hidden name=root value="$form->{root}">
1078 <input type=hidden name=path value=$form->{path}>
1079 <input type=hidden name=rpw value=$form->{rpw}>
1082 <input type=submit class=submit name=action value="|.$locale->text('Change Password').qq|">
1093 sub change_password {
1095 $root->{password} = $form->{password};
1097 $root->{'root login'} = 1;
1098 $root->save_member($memberfile);
1100 $form->{callback} = "$form->{script}?action=list_users&path=$form->{path}&root=$form->{root}&rpw=$root->{password}";
1102 $form->redirect($locale->text('Password changed!'));
1107 sub check_password {
1109 $root = new User "$memberfile", $form->{root};
1111 if ($root->{password}) {
1112 if ($root->{password} ne $form->{rpw}) {
1113 $form->error($locale->text('Incorrect Password!'));
1120 sub pg_database_administration {
1122 $form->{dbdriver} = 'Pg';
1128 sub oracle_database_administration {
1130 $form->{dbdriver} = 'Oracle';
1136 sub dbdriver_defaults {
1138 # load some defaults for the selected driver
1139 %driverdefaults = ( 'Pg' => { dbport => '5432',
1140 dbuser => 'postgres',
1141 dbdefault => 'template1',
1142 dbhost => 'localhost',
1143 connectstring => $locale->text('Connect to')
1145 'Oracle' => { dbport => '1521',
1148 dbhost => `hostname`,
1149 connectstring => 'SID'
1153 map { $form->{$_} = $driverdefaults{$form->{dbdriver}}{$_} } keys %{ $driverdefaults{Pg} };
1158 sub dbselect_source {
1162 $msg{Pg} = $locale->text('Leave host and port field empty unless you want to make a remote connection.');
1163 $msg{Oracle} = $locale->text('You must enter a host and port for local and remote connections!');
1166 $form->{title} = "Lx-Office ERP / ".$locale->text('Database Administration');
1176 <h2>$form->{title}</h2>
1178 <form method=post action=$form->{script}>
1185 <tr class=listheading>
1186 <th colspan=4>|.$locale->text('Database').qq|</th>
1189 <input type=hidden name=dbdriver value=$form->{dbdriver}>
1196 <th align=right>|.$locale->text('Host').qq|</th>
1197 <td><input name=dbhost size=25 value=$form->{dbhost}></td>
1198 <th align=right>|.$locale->text('Port').qq|</th>
1199 <td><input name=dbport size=5 value=$form->{dbport}></td>
1205 <th align=right>|.$locale->text('User').qq|</th>
1206 <td><input name=dbuser size=10 value=$form->{dbuser}></td>
1207 <th align=right>|.$locale->text('Password').qq|</th>
1208 <td><input type=password name=dbpasswd size=10></td>
1214 <th align=right>$form->{connectstring}</th>
1215 <td colspan=3><input name=dbdefault size=10 value=$form->{dbdefault}></td>
1224 <input name=callback type=hidden value="$form->{script}?action=list_users&path=$form->{path}&root=$form->{root}&rpw=$form->{rpw}">
1225 <input type=hidden name=root value="$form->{root}">
1226 <input type=hidden name=path value=$form->{path}>
1227 <input type=hidden name=rpw value=$form->{rpw}>
1231 <input type=submit class=submit name=action value="|.$locale->text('Create Dataset').qq|">
1232 <input type=submit class=submit name=action value="|.$locale->text('Update Dataset').qq|">
1233 <input type=submit class=submit name=action value="|.$locale->text('Delete Dataset').qq|">
1240 <p>|.$locale->text('This is a preliminary check for existing sources. Nothing will be created or deleted at this stage!')
1243 <br>$msg{$form->{dbdriver}}
1255 &{ $form->{nextsub} };
1260 sub update_dataset {
1262 %needsupdate = User->dbneedsupdate(\%$form);
1264 $form->{title} = "Lx-Office ERP ".$locale->text('Database Administration')." / ".$locale->text('Update Dataset');
1273 <h2>$form->{title}</h2>
1277 foreach $key (sort keys %needsupdate) {
1278 if ($needsupdate{$key} ne $form->{dbversion}) {
1279 $upd .= qq|<input name="db$key" type=checkbox value=1 checked> $key\n|;
1280 $form->{dbupdate} .= "db$key ";
1284 chop $form->{dbupdate};
1287 if ($form->{dbupdate}) {
1291 <form method=post action=$form->{script}>
1293 <input type=hidden name=dbdriver value=$form->{dbdriver}>
1294 <input type=hidden name=dbhost value=$form->{dbhost}>
1295 <input type=hidden name=dbport value=$form->{dbport}>
1296 <input type=hidden name=dbuser value=$form->{dbuser}>
1297 <input type=hidden name=dbpasswd value=$form->{dbpasswd}>
1298 <input type=hidden name=dbdefault value=$form->{dbdefault}>
1300 <tr class=listheading>
1301 <th>|.$locale->text('The following Datasets need to be updated').qq|</th>
1313 <input name=dbupdate type=hidden value="$form->{dbupdate}">
1315 <input name=callback type=hidden value="$form->{script}?action=list_users&path=$form->{path}&root=$form->{root}&rpw=$form->{rpw}">
1317 <input type=hidden name=root value="$form->{root}">
1318 <input type=hidden name=path value=$form->{path}>
1319 <input type=hidden name=rpw value=$form->{rpw}>
1321 <input type=hidden name=nextsub value=dbupdate>
1326 <input type=submit class=submit name=action value="|.$locale->text('Continue').qq|">
1335 print $locale->text('All Datasets up to date!');
1350 User->dbupdate(\%$form);
1352 $form->redirect($locale->text('Dataset updated!'));
1357 sub create_dataset {
1359 foreach $item (sort User->dbsources(\%$form)) {
1360 $dbsources .= "[$item] ";
1363 opendir SQLDIR, "sql/." or $form-error($!);
1364 foreach $item (sort grep /-chart\.sql/, readdir SQLDIR) {
1365 next if ($item eq 'Default-chart.sql');
1366 $item =~ s/-chart\.sql//;
1367 push @charts, qq| <input name=chart class=radio type=radio value="$item"> $item|;
1371 $selectencoding = qq|<option>
1372 <option value=SQL_ASCII>ASCII
1373 <option value=EUC_JP>Japanese Extended UNIX Code
1374 <option value=EUC_CN>Chinese Extended UNIX Code
1375 <option value=EUC_KR>Korean Extended UNIX Code
1376 <option value=EUC_TW>Taiwan Extended UNIX Code
1377 <option value=UNICODE>UTF-8 Unicode
1378 <option value=MULE_INTERNAL>Mule internal type
1379 <option value=LATIN1>ISO 8859-1
1380 <option value=LATIN2>ISO 8859-2
1381 <option value=LATIN3>ISO 8859-3
1382 <option value=LATIN4>ISO 8859-4
1383 <option value=LATIN5>ISO 8859-5
1384 <option value=KOI8>KOI8-R
1385 <option value=WIN>Windows CP1251
1386 <option value=ALT>Windows CP866
1389 $form->{title} = "Lx-Office ERP ".$locale->text('Database Administration')." / ".$locale->text('Create Dataset');
1398 <h2>$form->{title}</h2>
1400 <form method=post action=$form->{script}>
1403 <tr class=listheading>
1404 <th colspan=2> </th>
1409 <th align=right nowrap>|.$locale->text('Existing Datasets').qq|</th>
1416 <th align=right nowrap>|.$locale->text('Create Dataset').qq|</th>
1417 <td><input name=db></td>
1423 <th align=right nowrap>|.$locale->text('Multibyte Encoding').qq|</th>
1424 <td><select name=encoding>$selectencoding</select></td>
1430 <th align=right nowrap>|.$locale->text('Create Chart of Accounts').qq|</th>
1437 <input type=hidden name=dbdriver value=$form->{dbdriver}>
1438 <input type=hidden name=dbuser value=$form->{dbuser}>
1439 <input type=hidden name=dbhost value=$form->{dbhost}>
1440 <input type=hidden name=dbport value=$form->{dbport}>
1441 <input type=hidden name=dbpasswd value=$form->{dbpasswd}>
1442 <input type=hidden name=dbdefault value=$form->{dbdefault}>
1444 <input name=callback type=hidden value="$form->{script}?action=list_users&path=$form->{path}&root=$form->{root}&rpw=$form->{rpw}">
1446 <input type=hidden name=root value="$form->{root}">
1447 <input type=hidden name=path value=$form->{path}>
1448 <input type=hidden name=rpw value=$form->{rpw}>
1450 <input type=hidden name=nextsub value=dbcreate>
1455 <input type=submit class=submit name=action value="|.$locale->text('Continue').qq|">
1472 $form->isblank("db", $locale->text('Dataset missing!'));
1474 User->dbcreate(\%$form);
1476 $form->{title} = "Lx-Office ERP ".$locale->text('Database Administration')." / ".$locale->text('Create Dataset');
1485 <h2>$form->{title}</h2>
1487 <form method=post action=$form->{script}>|
1489 .$locale->text('Dataset')." $form->{db} ".$locale->text('successfully created!')
1493 <input type=hidden name=root value="$form->{root}">
1494 <input type=hidden name=path value="$form->{path}">
1495 <input type=hidden name=rpw value="$form->{rpw}">
1497 <input type=hidden name=nextsub value=list_users>
1499 <p><input type=submit class=submit name=action value="|.$locale->text('Continue').qq|">
1510 sub delete_dataset {
1512 if (@dbsources = User->dbsources_unused(\%$form, $memberfile)) {
1513 foreach $item (sort @dbsources) {
1514 $dbsources .= qq|<input name=db class=radio type=radio value=$item> $item |;
1517 $form->error($locale->text('Nothing to delete!'));
1520 $form->{title} = "Lx-Office ERP ".$locale->text('Database Administration')." / ".$locale->text('Delete Dataset');
1527 <h2>$form->{title}</h2>
1529 <form method=post action=$form->{script}>
1532 <tr class=listheading>
1533 <th>|.$locale->text('The following Datasets are not in use and can be deleted').qq|</th>
1544 <input type=hidden name=dbdriver value=$form->{dbdriver}>
1545 <input type=hidden name=dbuser value=$form->{dbuser}>
1546 <input type=hidden name=dbhost value=$form->{dbhost}>
1547 <input type=hidden name=dbport value=$form->{dbport}>
1548 <input type=hidden name=dbpasswd value=$form->{dbpasswd}>
1549 <input type=hidden name=dbdefault value=$form->{dbdefault}>
1551 <input name=callback type=hidden value="$form->{script}?action=list_users&path=$form->{path}&root=$form->{root}&rpw=$form->{rpw}">
1553 <input type=hidden name=root value="$form->{root}">
1554 <input type=hidden name=path value="$form->{path}">
1555 <input type=hidden name=rpw value="$form->{rpw}">
1557 <input type=hidden name=nextsub value=dbdelete>
1562 <input type=submit class=submit name=action value="|.$locale->text('Continue').qq|">
1579 $form->error($locale->text('No Dataset selected!'));
1582 User->dbdelete(\%$form);
1584 $form->{title} = "Lx-Office ERP ".$locale->text('Database Administration')." / ".$locale->text('Delete Dataset');
1593 <h2>$form->{title}</h2>
1595 <form method=post action=$form->{script}>
1597 $form->{db} |.$locale->text('successfully deleted!')
1601 <input type=hidden name=root value="$form->{root}">
1602 <input type=hidden name=path value="$form->{path}">
1603 <input type=hidden name=rpw value="$form->{rpw}">
1605 <input type=hidden name=nextsub value=list_users>
1607 <p><input type=submit class=submit name=action value="|.$locale->text('Continue').qq|">
1620 unlink "$userspath/nologin";
1622 $form->{callback} = "$form->{script}?action=list_users&path=$form->{path}&root=$form->{root}&rpw=$root->{password}";
1624 $form->redirect($locale->text('Lockfile removed!'));
1631 open(FH, ">$userspath/nologin") or $form->error($locale->text('Cannot create Lock!'));
1634 $form->{callback} = "$form->{script}?action=list_users&path=$form->{path}&root=$form->{root}&rpw=$root->{password}";
1636 $form->redirect($locale->text('Lockfile created!'));