Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 296b4f44

Von Moritz Bunkus vor mehr als 17 Jahren hinzugefügt

  • ID 296b4f44a5ba0b3d3a172c8de4c884b34737a33d
  • Vorgänger a6199e53
  • Nachfolger 86f876b6

Einige Funktionen in admin.pl auf die Verwendung von HTML-Vorlagen umgestellt.

Unterschiede anzeigen:

bin/mozilla/admin.pl
105 105
  $form->{title} =
106 106
    qq|Lx-Office ERP $form->{version} | . $locale->text('Administration');
107 107

  
108
  $form->header;
109

  
110
  print qq|
111
<body class=admin>
112

  
108
  $form->header();
109
  print $form->parse_html_template('admin/adminlogin');
110
}
113 111

  
114
<div align=center>
112
sub login {
113
  list_users();
114
}
115 115

  
116
<a href="http://www.lx-office.org"><img src="image/lx-office-erp.png" border=0></a>
117
<h1 class=login>|
118
    . $locale->text('Version')
119
    . qq| $form->{version}<p>|
120
    . $locale->text('Administration')
121
    . qq|</h1>
116
sub list_users {
122 117

  
123
<form method=post action="$form->{script}">
118
  $form->error($locale->text('File locked!')) if (-f "${memberfile}.LCK");
124 119

  
125
<table>
126
  <tr>
127
    <th>| . $locale->text('Password') . qq|</th>
128
    <td><input type=password name=rpw></td>
129
    <td><input type=submit class=submit name=action value="|
130
    . $locale->text('Login') . qq|"></td>
131
  </tr>
132
<input type=hidden name=action value=login>
133
</table>
120
  open(FH, "$memberfile") or $form->error("$memberfile : $!");
134 121

  
122
  my %members;
135 123

  
136
</form>
124
  while (<FH>) {
125
    chomp;
137 126

  
138
<a href=http://www.lx-office.org>Lx-Office |
139
    . $locale->text('website') . qq|</a>
127
    if (/^\[.*\]/) {
128
      $login = $_;
129
      $login =~ s/(\[|\])//g;
140 130

  
141
</div>
131
      $members{$login} = { "login" => $login };
132
    }
142 133

  
143
</body>
144
</html>
145
|;
134
    if (/^([a-z]+)=(.*)/) {
135
      $members{$login}->{$1} = $2;
136
    }
137
  }
146 138

  
147
}
139
  close(FH);
148 140

  
149
sub login {
141
  delete $members{"root login"};
142
  map { $_->{templates} =~ s|.*/||; } values %members;
150 143

  
151
  &list_users;
144
  $form->{title}  = "Lx-Office ERP " . $locale->text('Administration');
145
  $form->{LOCKED} = -e "$userspath/nologin";
146
  $form->{MEMBERS} = [ @members{sort { lc $a cmp lc $b } keys %members} ];
152 147

  
148
  $form->header();
149
  print $form->parse_html_template("admin/list_users");
153 150
}
154 151

  
155 152
sub add_user {
......
166 163
  if (-f "css/lx-office-erp.css") {
167 164
    $myconfig->{stylesheet} = "lx-office-erp.css";
168 165
  }
169
  $myconfig->{vclimit} = 200;
170 166

  
171
  $myconfig->{"countrycode"} = "de";
172
  $myconfig->{"numberformat"} = "1000,00";
173
  $myconfig->{"dateformat"} = "dd.mm.yy";
167
  $myconfig->{vclimit}      = 200;
168
  $myconfig->{countrycode}  = "de";
169
  $myconfig->{numberformat} = "1000,00";
170
  $myconfig->{dateformat}   = "dd.mm.yy";
174 171

  
175 172
  &form_header;
176 173
  &form_footer;
......
216 213

  
217 214
}
218 215

  
219
sub list_users {
220

  
221
  $form->error($locale->text('File locked!')) if (-f "${memberfile}.LCK");
222

  
223
  open(FH, "$memberfile") or $form->error("$memberfile : $!");
224

  
225
  $nologin = qq|
226
<input type=submit class=submit name=action value="|
227
    . $locale->text('Lock System') . qq|">|;
228

  
229
  if (-e "$userspath/nologin") {
230
    $nologin = qq|
231
<input type=submit class=submit name=action value="|
232
      . $locale->text('Unlock System') . qq|">|;
233
  }
234

  
235
  while (<FH>) {
236
    chop;
237

  
238
    if (/^\[.*\]/) {
239
      $login = $_;
240
      $login =~ s/(\[|\])//g;
241
    }
242

  
243
    if (/^(name=|company=|templates=|dbuser=|dbdriver=|dbname=|dbhost=)/) {
244
      chop($var = $&);
245
      ($null, $member{$login}{$var}) = split(/=/, $_, 2);
246
    }
247
  }
248

  
249
  close(FH);
250

  
251
  # type=submit $locale->text('Pg Database Administration')
252
  # type=submit $locale->text('Oracle Database Administration')
253

  
254
  foreach $item (User->dbdrivers) {
255
    $dbdrivers .=
256
      qq|<input name=action type=submit class=submit value="|
257
      . $locale->text("$item Database Administration") . qq|">|;
258
  }
259

  
260
  $column_header{login}     = qq|<th>| . $locale->text('Login') . qq|</th>|;
261
  $column_header{name}      = qq|<th>| . $locale->text('Name') . qq|</th>|;
262
  $column_header{company}   = qq|<th>| . $locale->text('Company') . qq|</th>|;
263
  $column_header{dbdriver}  = qq|<th>| . $locale->text('Driver') . qq|</th>|;
264
  $column_header{dbhost}    = qq|<th>| . $locale->text('Host') . qq|</th>|;
265
  $column_header{dataset}   = qq|<th>| . $locale->text('Dataset') . qq|</th>|;
266
  $column_header{templates} =
267
    qq|<th>| . $locale->text('Templates') . qq|</th>|;
268

  
269
  @column_index = qw(login name company dbdriver dbhost dataset templates);
270

  
271
  $form->{title} = "Lx-Office ERP " . $locale->text('Administration');
272

  
273
  $form->header;
274

  
275
  print qq|
276
<body class=admin>
277

  
278
<form method=post action=$form->{script}>
279

  
280
<table width=100%>
281
  <tr>
282
  <tr class=listheading>
283
    <th>$form->{title}</th>
284
  </tr>
285
  <tr size=5></tr>
286
  <tr>
287
    <td>
288
      <table width=100%>
289
        <tr class=listheading>|;
290

  
291
  map { print "$column_header{$_}\n" } @column_index;
292

  
293
  print qq|
294
        </tr>
295
|;
296

  
297
  foreach $key (sort keys %member) {
298
    $href =
299
      "$script?action=edit&login=$key&rpw=$form->{rpw}";
300
    $href =~ s/ /%20/g;
301

  
302
    $member{$key}{templates} =~ s/^$templates\///;
303
    $member{$key}{dbhost} = $locale->text('localhost')
304
      unless $member{$key}{dbhost};
305
    $member{$key}{dbname} = $member{$key}{dbuser}
306
      if ($member{$key}{dbdriver} eq 'Oracle');
307

  
308
    $column_data{login}     = qq|<td><a id="$key" href="$href">$key</a></td>|;
309
    $column_data{name}      = qq|<td>$member{$key}{name}</td>|;
310
    $column_data{company}   = qq|<td>$member{$key}{company}</td>|;
311
    $column_data{dbdriver}  = qq|<td>$member{$key}{dbdriver}</td>|;
312
    $column_data{dbhost}    = qq|<td>$member{$key}{dbhost}</td>|;
313
    $column_data{dataset}   = qq|<td>$member{$key}{dbname}</td>|;
314
    $column_data{templates} = qq|<td>$member{$key}{templates}</td>|;
315

  
316
    $i++;
317
    $i %= 2;
318
    print qq|
319
        <tr class="listrow$i">|;
320

  
321
    map { print "$column_data{$_}\n" } @column_index;
322

  
323
    print qq|
324
        </tr>|;
325
  }
326

  
327
  print qq|
328
      </table>
329
    </td>
330
  </tr>
331
  <tr>
332
    <td><hr size=3 noshade></td>
333
  </tr>
334
</table>
335

  
336
<input type=hidden name=rpw value=$form->{rpw}>
337

  
338
<br><input type=submit class=submit name=action value="|
339
    . $locale->text('Add User') . qq|">
340
<input type=submit class=submit name=action value="|
341
    . $locale->text('Change Admin Password') . qq|">
342

  
343
$dbdrivers
344
$nologin
345

  
346
</form>
347

  
348
| . $locale->text('Click on login name to edit!') . qq|
349
<br>
350
|
351
    . $locale->text(
352
    '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.'
353
    )
354
    . qq|
355

  
356
<p>
357

  
358
<form method=post action=login.pl>
359

  
360
<table border=0 width=100%>
361
  <tr class=listheading>
362
    <th>Lx-Office ERP | . $locale->text('Login') . qq|</th>
363
  </tr>
364
  <tr>
365
    <td>
366
      <table>
367
        <tr>
368
	  <th align=right>| . $locale->text('Name') . qq|</th>
369
	  <td><input class=login name=login></td>
370
	  <td>&nbsp;</td>
371
	</tr>
372
	<tr>
373
	  <th align=right>| . $locale->text('Password') . qq|</th>
374
	  <td><input class=login type=password name=password></td>
375
	  <td><input type=submit name=action value="|
376
    . $locale->text('Login') . qq|"></td>
377
	</tr>
378
      </table>
379
    </td>
380
  </tr>
381
</table>
382

  
383
</form>
384

  
385
<hr size=3 noshade>
386

  
387
</body>
388
</html>
389
|;
390

  
391
}
392

  
393 216
sub form_header {
394 217

  
395 218
  # if there is a login, get user
......
1121 944
    . $locale->text('Administration') . " / "
1122 945
    . $locale->text('Change Admin Password');
1123 946

  
1124
  $form->header;
1125

  
1126
  print qq|
1127
<body class=admin>
1128

  
1129

  
1130
<h2>| . $locale->text('Change Admin Password') . qq|</h2>
1131

  
1132
<form method=post action=$form->{script}>
1133

  
1134
<table>
1135
  <tr>
1136
    <td><b>| . $locale->text('Password') . qq|</b></td>
1137
    <td><input type=password name=password size=8></td>
1138
  </tr>
1139
  <tr>
1140
    <td><b>| . $locale->text('Repeat the password') . qq|</b></td>
1141
    <td><input type=password name=password_again size=8></b></td>
1142
  </tr>
1143
</table>
1144

  
1145
<input type=hidden name=rpw value=$form->{rpw}>
1146

  
1147
<p>
1148
<input type=submit class=submit name=action value="|
1149
    . $locale->text('Change Password') . qq|">
1150

  
1151
</form>
1152

  
1153
</body>
1154
</html>
1155
|;
1156

  
947
  $form->header();
948
  print $form->parse_html_template("admin/change_admin_password");
1157 949
}
1158 950

  
1159 951
sub change_password {
......
1163 955
      . $locale->text('Administration') . " / "
1164 956
      . $locale->text('Change Admin Password');
1165 957

  
1166
    $form->header;
1167

  
1168
    print qq|
1169
<body class=admin>
1170

  
1171

  
1172
<h2>| . $locale->text('Change Admin Password') . qq|</h2>
1173

  
1174
<p>| . $locale->text("The passwords do not match.") . qq|<br>
1175
<input type="button" onclick="history.back()" value="| . $locale->text("Back") . qq|">|;
1176
    return;
958
    $form->header();
959
    $form->error($locale->text("The passwords do not match."));
1177 960
  }
1178 961

  
1179 962
  $root->{password} = $form->{password};
......
1185 968
    "$form->{script}?action=list_users&rpw=$root->{password}";
1186 969

  
1187 970
  $form->redirect($locale->text('Password changed!'));
1188

  
1189 971
}
1190 972

  
1191 973
sub check_password {
......
1456 1238
}
1457 1239

  
1458 1240
sub create_dataset {
1241
  $form->{dbsources} = join " ", map { "[${_}]" } sort User->dbsources(\%$form);
1459 1242

  
1460
  foreach $item (sort User->dbsources(\%$form)) {
1461
    $dbsources .= "[$item] ";
1462
  }
1243
  $form->{CHARTS} = [];
1463 1244

  
1464 1245
  opendir SQLDIR, "sql/." or $form - error($!);
1465 1246
  foreach $item (sort grep /-chart\.sql\z/, readdir SQLDIR) {
1466 1247
    next if ($item eq 'Default-chart.sql');
1467 1248
    $item =~ s/-chart\.sql//;
1468
    push @charts,
1469
      qq| <input name=chart class=radio type=radio value="$item">&nbsp;$item|;
1249
    push @{ $form->{CHARTS} }, { "name"     => $item,
1250
                                 "selected" => $item eq "Germany-DATEV-SKR03EU" };
1470 1251
  }
1471 1252
  closedir SQLDIR;
1472 1253

  
1473
  my (@values, %labels);
1474

  
1475 1254
  my $default_charset = $dbcharset;
1476 1255
  $default_charset ||= Common::DEFAULT_CHARSET;
1477
  my $default_encoding;
1478 1256

  
1479
  foreach my $encoding (@Common::db_encodings) {
1480
    push @values, $encoding->{dbencoding};
1481
    $labels{$encoding->{dbencoding}} = $encoding->{label};
1257
  $form->{DBENCODINGS} = [];
1482 1258

  
1483
    $default_encoding = $encoding->{dbencoding} if $encoding->{charset} eq $default_charset;
1259
  foreach my $encoding (@Common::db_encodings) {
1260
    push @{ $form->{DBENCODINGS} }, { "dbencoding" => $encoding->{dbencoding},
1261
                                      "label"      => $encoding->{label},
1262
                                      "selected"   => $encoding->{charset} eq $default_charset };
1484 1263
  }
1485 1264

  
1486
  $selectencoding =
1487
    NTI($cgi->popup_menu('-name' => 'encoding',
1488
                         '-values' => \@values,
1489
                         '-labels' => \%labels,
1490
                         '-default' => $default_encoding));
1491

  
1492 1265
  $form->{title} =
1493 1266
      "Lx-Office ERP "
1494 1267
    . $locale->text('Database Administration') . " / "
1495 1268
    . $locale->text('Create Dataset');
1496 1269

  
1497
  $form->header;
1498

  
1499
  print qq|
1500
<body class=admin>
1501

  
1502

  
1503
<center>
1504
<h2>$form->{title}</h2>
1505

  
1506
<form method=post action=$form->{script}>
1507

  
1508
<table width=100%>
1509
  <tr class=listheading>
1510
    <th colspan=2>&nbsp;</th>
1511
  </tr>
1512

  
1513
  <tr>
1514

  
1515
    <th align=right nowrap>| . $locale->text('Existing Datasets') . qq|</th>
1516
    <td>$dbsources</td>
1517

  
1518
  </tr>
1519

  
1520
  <tr>
1521

  
1522
    <th align=right nowrap>| . $locale->text('Create Dataset') . qq|</th>
1523
    <td><input name=db></td>
1524

  
1525
  </tr>
1526

  
1527
  <tr>
1528

  
1529
    <th align=right nowrap>| . $locale->text('Multibyte Encoding') . qq|</th>
1530
    <td>$selectencoding</td>
1531

  
1532
  </tr>
1533

  
1534
  <tr>
1535

  
1536
    <th align=right nowrap>|
1537
    . $locale->text('Create Chart of Accounts') . qq|</th>
1538
    <td>@charts</td>
1539

  
1540
  </tr>
1541

  
1542
  <tr><td colspan=2>
1543
<p>
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}">
1550

  
1551
<input name=callback type=hidden value="$form->{script}?action=list_users&rpw=$form->{rpw}">
1552

  
1553
<input type=hidden name=rpw value=$form->{rpw}>
1554

  
1555
<input type=hidden name=nextsub value=dbcreate>
1556

  
1557
<hr size=3 noshade>
1558

  
1559
<br>
1560
<input type=submit class=submit name=action value="|
1561
    . $locale->text('Continue') . qq|">
1562

  
1563
  </td></tr>
1564
</table>
1565

  
1566
</form>
1567

  
1568

  
1569
</body>
1570
</html>
1571
|;
1572

  
1270
  $form->header();
1271
  print $form->parse_html_template("admin/create_dataset");
1573 1272
}
1574 1273

  
1575 1274
sub dbcreate {
1576

  
1577 1275
  $form->isblank("db", $locale->text('Dataset missing!'));
1578 1276

  
1579 1277
  User->dbcreate(\%$form);
......
1583 1281
    . $locale->text('Database Administration') . " / "
1584 1282
    . $locale->text('Create Dataset');
1585 1283

  
1586
  $form->header;
1587

  
1588
  print qq|
1589
<body class=admin>
1590

  
1591

  
1592
<center>
1593
<h2>$form->{title}</h2>
1594

  
1595
<form method=post action=$form->{script}>|
1596

  
1597
    . $locale->text('Dataset')
1598
    . " $form->{db} "
1599
    . $locale->text('successfully created!')
1600

  
1601
    . qq|
1602

  
1603
<input type=hidden name=rpw value="$form->{rpw}">
1604

  
1605
<input type=hidden name=nextsub value=list_users>
1606

  
1607
<p><input type=submit class=submit name=action value="|
1608
    . $locale->text('Continue') . qq|">
1609
</form>
1610

  
1611

  
1612
</body>
1613
</html>
1614
|;
1615

  
1284
  $form->header();
1285
  print $form->parse_html_template("admin/dbcreate");
1616 1286
}
1617 1287

  
1618 1288
sub delete_dataset {
1619

  
1620
  if (@dbsources = User->dbsources_unused(\%$form, $memberfile)) {
1621
    foreach $item (sort @dbsources) {
1622
      $dbsources .=
1623
        qq|<input name=db class=radio type=radio value=$item>&nbsp;$item |;
1624
    }
1625
  } else {
1626
    $form->error($locale->text('Nothing to delete!'));
1627
  }
1289
  @dbsources = User->dbsources_unused(\%$form, $memberfile);
1290
  $form->error($locale->text('Nothing to delete!')) unless @dbsources;
1628 1291

  
1629 1292
  $form->{title} =
1630 1293
      "Lx-Office ERP "
1631 1294
    . $locale->text('Database Administration') . " / "
1632 1295
    . $locale->text('Delete Dataset');
1296
  $form->{DBSOURCES} = [ map { { "name", $_ } } sort @dbsources ];
1633 1297

  
1634
  $form->header;
1635

  
1636
  print qq|
1637
<body class=admin>
1638

  
1639
<h2>$form->{title}</h2>
1640

  
1641
<form method=post action=$form->{script}>
1642

  
1643
<table width=100%>
1644
  <tr class=listheading>
1645
    <th>|
1646
    . $locale->text('The following Datasets are not in use and can be deleted')
1647
    . qq|</th>
1648
  </tr>
1649

  
1650
  <tr>
1651
    <td>
1652
    $dbsources
1653
    </td>
1654
  </tr>
1655

  
1656
  <tr><td>
1657
<p>
1658
<input type=hidden name="dbdriver"  value="$form->{dbdriver}">
1659
<input type=hidden name="dbuser"    value="$form->{dbuser}">
1660
<input type=hidden name="dbhost"    value="$form->{dbhost}">
1661
<input type=hidden name="dbport"    value="$form->{dbport}">
1662
<input type=hidden name="dbpasswd"  value="$form->{dbpasswd}">
1663
<input type=hidden name="dbdefault" value="$form->{dbdefault}">
1664

  
1665
<input name=callback type=hidden value="$form->{script}?action=list_users&rpw=$form->{rpw}">
1666

  
1667
<input type=hidden name=rpw value="$form->{rpw}">
1668

  
1669
<input type=hidden name=nextsub value=dbdelete>
1670

  
1671
<hr size=3 noshade>
1672

  
1673
<br>
1674
<input type=submit class=submit name=action value="|
1675
    . $locale->text('Continue') . qq|">
1676

  
1677
  </td></tr>
1678
</table>
1679

  
1680
</form>
1681

  
1682
</body>
1683
</html>
1684
|;
1685

  
1298
  $form->header();
1299
  print $form->parse_html_template("admin/delete_dataset");
1686 1300
}
1687 1301

  
1688 1302
sub dbdelete {
......
1698 1312
    . $locale->text('Database Administration') . " / "
1699 1313
    . $locale->text('Delete Dataset');
1700 1314

  
1701
  $form->header;
1702

  
1703
  print qq|
1704
<body class=admin>
1705

  
1706

  
1707
<center>
1708
<h2>$form->{title}</h2>
1709

  
1710
<form method=post action=$form->{script}>
1711

  
1712
$form->{db} | . $locale->text('successfully deleted!')
1713

  
1714
    . qq|
1715

  
1716
<input type=hidden name=rpw value="$form->{rpw}">
1717

  
1718
<input type=hidden name=nextsub value=list_users>
1719

  
1720
<p><input type=submit class=submit name=action value="|
1721
    . $locale->text('Continue') . qq|">
1722
</form>
1723

  
1724

  
1725
</body>
1726
</html>
1727
|;
1728

  
1315
  $form->header();
1316
  print $form->parse_html_template("admin/dbdelete");
1729 1317
}
1730 1318

  
1731 1319
sub unlock_system {

Auch abrufbar als: Unified diff