summaryrefslogtreecommitdiff
path: root/po
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2008-08-15 12:38:12 +0200
committerJonas Smedegaard <dr@jones.dk>2008-08-15 12:38:12 +0200
commitbc06d9c59525a59282ca8ba1e46aa04d1770fd19 (patch)
treeb68c77e547f66955df7792ca224085ee9e1d6950 /po
parent77a654a44ffcb8b62d24bba6223637f86278143a (diff)
Use _l10n/xx (not _xx) for locale content.
Diffstat (limited to 'po')
0 files changed, 0 insertions, 0 deletions
class="hl kwa">use LedgerSMB::Form;
  • use LedgerSMB::Locale;
  • use LedgerSMB::User;
  • use LedgerSMB::Session;
  • $form = new Form;
  • $locale = LedgerSMB::Locale->get_handle( ${LedgerSMB::Sysconfig::language} )
  • or
  • $form->error( __FILE__ . ':' . __LINE__ . ': ' . "Locale not loaded: $!\n" );
  • $locale->encoding('UTF-8');
  • $form->{charset} = 'UTF-8';
  • eval { require DBI; };
  • $form->error(
  • __FILE__ . ':' . __LINE__ . ': ' . $locale->text('DBI not installed!') )
  • if ($@);
  • $form->{stylesheet} = "ledger-smb.css";
  • $form->{favicon} = "favicon.ico";
  • $form->{timeout} = 600;
  • require "bin/pw.pl";
  • # customization
  • if ( -f "bin/custom/$form->{script}" ) {
  • eval { require "bin/custom/$form->{script}"; };
  • $form->error( __FILE__ . ':' . __LINE__ . ': ' . $@ ) if ($@);
  • }
  • if ( $form->{action} ) {
  • &check_password unless $form->{action} eq 'logout';
  • &{ $form->{action} };
  • }
  • else {
  • # if there are no drivers bail out
  • $form->error( __FILE__ . ':' . __LINE__ . ': '
  • . $locale->text('No Database Drivers available!') )
  • unless ( LedgerSMB::User->dbdrivers );
  • $root = LedgerSMB::User->new('admin');
  • &adminlogin;
  • }
  • 1;
  • # end
  • sub adminlogin {
  • my ($errorMessage) = @_;
  • $form->{title} =
  • qq|LedgerSMB $form->{version} | . $locale->text('Administration');
  • $myheaderadd = qq|
  • <script language="JavaScript" type="text/javascript">
  • <!--
  • function sf(){
  • document.admin.password.focus();
  • }
  • // End -->
  • </script>
  • |;
  • $form->header( undef, $myheaderadd );
  • print qq|
  • <body class="admin" onload="sf()">
  • <div align="center">
  • <a href="http://www.ledgersmb.org/"><img src="ledger-smb.png" width="200" height="100" border="0" alt="LedgerSMB Logo" /></a>
  • <h1 class="login">|
  • . $locale->text('Version')
  • . qq| $form->{version} <br />|
  • . $locale->text('Administration')
  • . qq|</h1>
  • <form method="post" action="admin.pl" name="admin">
  • <table>
  • <tr>
  • <th>| . $locale->text('Password') . qq|</th>
  • <td><input type="password" name="password" /></td>
  • <td><button type="submit" class="submit" name="action" value="login">|
  • . $locale->text('Login')
  • . qq|</button></td>
  • </tr>
  • </table>
  • <input type="hidden" name="action" value="login" />
  • <input type="hidden" name="path" value="$form->{path}" />
  • </form>
  • |;
  • if ($errorMessage) {
  • print
  • qq|<p><span style="font-weight:bold; color:red;">$errorMessage</span></p><br />|;
  • }
  • print qq|
  • <br /><br />
  • <p><a href="login.pl"
  • >| . $locale->text("Application Login") . qq|</a></p>
  • <br /><br />
  • <a style="font-size: 0.8em;" href="http://www.ledgersmb.org/">|
  • . $locale->text('LedgerSMB website') . qq|</a>
  • </div>
  • </body>
  • </html>
  • |;
  • }
  • sub login {
  • &list_users;
  • }
  • sub logout {
  • $form->{login} = 'admin';
  • $form->{callback} = "admin.pl?action=adminlogin";
  • Session::session_destroy($form);
  • $form->redirect( $locale->text('You are logged out') );
  • }
  • sub add_user {
  • $form->{title} =
  • "LedgerSMB "
  • . $locale->text('Accounting') . " "
  • . $locale->text('Administration') . " / "
  • . $locale->text('Add User');
  • if ( -f "css/ledger-smb.css" ) {
  • $myconfig->{stylesheet} = "ledger-smb.css";
  • }
  • $myconfig->{vclimit} = 1000;
  • $myconfig->{menuwidth} = 155;
  • $myconfig->{timeout} = 3600;
  • &form_header;
  • &form_footer;
  • }
  • sub edit {
  • $form->{title} =
  • "LedgerSMB "
  • . $locale->text('Accounting') . " "
  • . $locale->text('Administration') . " / "
  • . $locale->text('Edit User');
  • $form->{edit} = 1;
  • &form_header;
  • &form_footer;
  • }
  • sub form_footer {
  • if ( $form->{edit} ) {
  • $delete =
  • qq|<button type="submit" class="submit" name="action" value="delete">|
  • . $locale->text('Delete')
  • . qq|</button>
  • <input type="hidden" name="edit" value="1" />|;
  • }
  • print qq|
  • <input name="callback" type="hidden" value="$form->{script}?action=list_users&amp;path=$form->{path}" />
  • <input type="hidden" name="path" value="$form->{path}" />
  • <button type="submit" class="submit" name="action" value="save">|
  • . $locale->text('Save')
  • . qq|</button>
  • $delete
  • </form>
  • </body>
  • </html>
  • |;
  • }
  • sub list_users {
  • # use the central database handle
  • my $dbh = ${LedgerSMB::Sysconfig::GLOBALDBH};
  • my $fetchMembers = $dbh->selectall_arrayref(
  • "SELECT uc.name, uc.company, uc.templates,
  • uc.dbuser, uc.dbdriver, uc.dbname,
  • uc.dbhost, u.username
  • FROM users as u, users_conf as uc
  • WHERE u.id = uc.id
  • AND u.id > 1
  • ORDER BY u.username;", { Slice => {} }
  • );
  • my @memberArray = ();
  • my @member = ();
  • foreach my $memberArray (@$fetchMembers) {
  • $member{ $memberArray->{username} } = $memberArray;
  • }
  • # type=submit $locale->text('Pg Database Administration')
  • # type=submit $locale->text('PgPP Database Administration')
  • foreach $item ( LedgerSMB::User->dbdrivers ) {
  • $dbdrivers .=
  • qq|<button name="action" type="submit" class="submit" value="|
  • . ( lc $item )
  • . '_database_administration">'
  • . $locale->text("$item Database Administration")
  • . qq|</button>|;
  • }
  • $column_header{login} = qq|<th>| . $locale->text('Login') . qq|</th>|;
  • $column_header{name} = qq|<th>| . $locale->text('Name') . qq|</th>|;
  • $column_header{company} = qq|<th>| . $locale->text('Company') . qq|</th>|;
  • $column_header{dbdriver} = qq|<th>| . $locale->text('Driver') . qq|</th>|;
  • $column_header{dbhost} = qq|<th>| . $locale->text('Host') . qq|</th>|;
  • $column_header{dataset} = qq|<th>| . $locale->text('Dataset') . qq|</th>|;
  • $column_header{templates} =
  • qq|<th>| . $locale->text('Templates') . qq|</th>|;
  • @column_index = qw(login name company dbdriver dbhost dataset templates);
  • $form->{title} =
  • "LedgerSMB "
  • . $locale->text('Accounting') . " "
  • . $locale->text('Administration');
  • $form->{login} = "admin";
  • $form->header;
  • print qq|
  • <body class="admin">
  • <form method="post" action="$form->{script}">
  • <table width="100%">
  • <tr class="listheading">
  • <th>$form->{title}</th>
  • </tr>
  • <tr size="5"></tr>
  • <tr>
  • <td>
  • <table width="100%">
  • <tr class="listheading">|;
  • for (@column_index) { print "$column_header{$_}\n" }
  • print qq| </tr>|;
  • foreach $key ( sort keys %member ) {
  • $href = "$script?action=edit&amp;login=$key&amp;path=$form->{path}";
  • $href =~ s/ /%20/g;
  • $member{$key}{templates} =~ s/^${LedgerSMB::Sysconfig::templates}\///;
  • $column_data{login} = qq|<td><a href="$href">$key</a></td>|;
  • $column_data{name} = qq|<td>$member{$key}{name}</td>|;
  • $column_data{company} = qq|<td>$member{$key}{company}</td>|;
  • $column_data{dbdriver} = qq|<td>$member{$key}{dbdriver}</td>|;
  • $column_data{dbhost} = qq|<td>$member{$key}{dbhost}</td>|;
  • $column_data{dataset} = qq|<td>$member{$key}{dbname}</td>|;
  • $column_data{templates} = qq|<td>$member{$key}{templates}</td>|;
  • $i++;
  • $i %= 2;
  • print qq| <tr class="listrow$i">|;
  • for (@column_index) { print "$column_data{$_}\n"; }
  • print qq| </tr>|;
  • }
  • print qq| </table>
  • </td>
  • </tr>
  • <tr>
  • <td><hr size="3" noshade /></td>
  • </tr>
  • </table>
  • <input type="hidden" name="path" value="$form->{path}" />
  • <br />
  • <button type="submit" class="submit" name="action" value="add_user">|
  • . $locale->text('Add User')
  • . qq|</button>
  • <button type="submit" class="submit" name="action" value="change_admin_password">|
  • . $locale->text('Change Admin Password')
  • . qq|</button>
  • $dbdrivers
  • <button type="submit" class="submit" name="action" value="logout">|
  • . $locale->text('Logout')
  • . qq|</button>
  • </form>
  • | . $locale->text('Click on login name to edit!') . qq|
  • <br />
  • |
  • . $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|
  • </body>
  • </html>|;
  • }
  • sub form_header {
  • # if there is a login, get user
  • if ( $form->{login} ) {
  • # get user
  • %{$myconfig} = %{ LedgerSMB::User->fetch_config( $form->{login} ) };
  • for (qw(company address signature)) {
  • $myconfig->{$_} = $form->quote( $myconfig->{$_} );
  • }
  • for (qw(address signature)) { $myconfig->{$_} =~ s/\\n/\n/g }
  • # strip basedir from templates directory
  • $myconfig->{templates} =~ s/^${LedgerSMB::Sysconfig::templates}\///;
  • }
  • foreach $item (qw(mm-dd-yy mm/dd/yy dd-mm-yy dd/mm/yy dd.mm.yy yyyy-mm-dd))
  • {
  • $dateformat .=
  • ( $item eq $myconfig->{dateformat} )
  • ? "<option selected>$item</option>\n"
  • : "<option>$item</option>\n";
  • }
  • my @formats = qw(1,000.00 1000.00 1.000,00 1000,00 1'000.00);
  • push @formats, '1 000.00';
  • foreach $item (@formats) {
  • $numberformat .=
  • ( $item eq $myconfig->{numberformat} )
  • ? "<option selected>$item</option>\n"
  • : "<option>$item</option>\n";
  • }
  • %countrycodes = LedgerSMB::User->country_codes;
  • $countrycodes = "";
  • my $selectedcode =
  • ( $myconfig->{countrycode} ) ? $myconfig->{countrycode} : 'en';
  • foreach $key ( sort { $countrycodes{$a} cmp $countrycodes{$b} }
  • keys %countrycodes )
  • {
  • $countrycodes .=
  • ( $selectedcode eq $key )
  • ? qq|<option selected value="$key">$countrycodes{$key}</option>|
  • : qq|<option value="$key">$countrycodes{$key}</option>|;
  • }
  • # is there a templates basedir
  • if ( !-d "${LedgerSMB::Sysconfig::templates}" ) {
  • $form->error(
  • __FILE__ . ':' . __LINE__ . ': '
  • . $locale->text(
  • 'Directory [_1] does not exist',
  • ${LedgerSMB::Sysconfig::templates}
  • )
  • );
  • }
  • opendir TEMPLATEDIR, "${LedgerSMB::Sysconfig::templates}/."
  • or $form->error( __FILE__ . ':' . __LINE__ . ': ' . "$templates : $!" );
  • @all = grep !/(^\.\.?$|^\.svn)/, readdir TEMPLATEDIR;
  • closedir TEMPLATEDIR;
  • @allhtml = sort grep /\.html/, @all;
  • @alldir = ();
  • for (@all) {
  • if ( -d "${LedgerSMB::Sysconfig::templates}/$_" ) {
  • push @alldir, $_;
  • }
  • }
  • @allhtml = reverse grep !/Default/, @allhtml;
  • push @allhtml, 'Default';
  • @allhtml = reverse @allhtml;
  • foreach $item ( sort @alldir ) {
  • if ( $item eq $myconfig->{templates} ) {
  • $usetemplates .=
  • qq|<option selected value="$item">$item</option>\n|;
  • }
  • else {
  • $usetemplates .= qq|<option value="$item">$item</option>\n|;
  • }
  • }
  • $lastitem = $allhtml[0];
  • $lastitem =~ s/-.*//g;
  • $mastertemplates = qq|<option value="$lastitem">$lastitem</option>\n|;