Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 8c7e4493

Von Moritz Bunkus vor fast 17 Jahren hinzugefügt

  • ID 8c7e44938a661e035f62840e1e177353240ace5d
  • Vorgänger 3ced230b
  • Nachfolger ce45d060

Umstellung der Benutzerverwaltung von Dateien im Verzeichnis "users" auf die Verwendung einer Authentifizierungsdatenbank.
Es ist erforderlich, die Dateien doc/UPGRADE und doc/INSTALL/index.html zu lesen und die angesprochenen Punkte auszuführen, um nach einem Upgrade weiter arbeiten zu können.

Unterschiede anzeigen:

bin/mozilla/common.pl
9 9
#
10 10
######################################################################
11 11

  
12
use SL::Form;
13 12
use SL::Common;
13
use SL::DBUtils;
14
use SL::Form;
14 15
use SL::MoreCommon;
15 16

  
16 17
sub build_std_url {
......
20 21

  
21 22
  my @parts;
22 23

  
23
  foreach my $key ((qw(login password), @_)) {
24
  foreach my $key (@_) {
24 25
    next unless ($key);
25 26

  
26 27
    if ($key =~ /(.*?)=(.*)/) {
......
31 32
      }
32 33

  
33 34
    } else {
34
      push @parts, "${key}=" . E($form->{$key});
35
      foreach my $var ($form->flatten_variables($key)) {
36
        push @parts, E($var->{key}) . '=' . E($var->{value});
37
      }
35 38
    }
36 39
  }
37 40

  
......
42 45
  return $url;
43 46
}
44 47

  
45
sub select_employee {
46
  $lxdebug->enter_sub();
47

  
48
  my ($callback_sub, @employees) = @_;
49

  
50
  if (0 == scalar(@employees)) {
51
    @employees = SystemBrace->get_all_employees(\%myconfig, $form);
52
  }
53

  
54
  my $old_form = save_form();
55

  
56
  $form->header();
57
  print($form->parse_html_template("generic/select_employee",
58
                                   { "EMPLOYEES" => \@employees,
59
                                     "old_form" => $old_form,
60
                                     "title" => $locale->text("Select an employee"),
61
                                     "nextsub" => "select_employee_internal",
62
                                     "callback_sub" => $callback_sub }));
63

  
64
  $lxdebug->leave_sub();
65
}
66

  
67
sub select_employee_internal {
68
  $lxdebug->enter_sub();
69

  
70
  my ($new_id, $new_name, $callback_sub);
71

  
72
  my $new_id = $form->{"new_id_" . $form->{"selection"}};
73
  my $new_name = $form->{"new_name_" . $form->{"selection"}};
74
  my $callback_sub = $form->{"callback_sub"};
75

  
76
  restore_form($form->{"old_form"});
77

  
78
  call_sub($callback_sub, $new_id, $new_name);
79

  
80
  $lxdebug->leave_sub();
81
}
48
# -------------------------------------------------------------------------
82 49

  
83 50
## Customers/Vendors
84 51

  
......
223 190
  my $old_form = save_form();
224 191

  
225 192
  $form->header();
226
  print($form->parse_html_template("generic/select_part",
227
                                   { "PARTS" => \@parts,
228
                                     "old_form" => $old_form,
229
                                     "title" => $locale->text("Select a part"),
230
                                     "nextsub" => "select_part_internal",
231
                                     "callback_sub" => $callback_sub,
232
                                     "has_charge" => $has_charge,
233
                                     "remap_parts_id" => $remap_parts_id,
234
                                     "remap_partnumber" => $remap_partnumber }));
193
  print $form->parse_html_template("generic/select_part",
194
                                   { "PARTS"            => \@parts,
195
                                     "old_form"         => $old_form,
196
                                     "title"            => $locale->text("Select a part"),
197
                                     "nextsub"          => "select_part_internal",
198
                                     "callback_sub"     => $callback_sub,
199
                                     "has_charge"       => $has_charge,
200
                                     "remap_parts_id"   => $remap_parts_id,
201
                                     "remap_partnumber" => $remap_partnumber });
235 202

  
236 203
  $lxdebug->leave_sub();
237 204
}
......
242 209
  my ($new_item, $callback_sub);
243 210

  
244 211
  my $re = "^new_.*_" . $form->{"selection"};
245
  map({
246
    my $key = $_;
247
    $key =~ s/^new_//;
248
    $key =~ s/_\d+$//;
249
    $new_item->{$key} = $form->{$_};
250
  } grep(/$re/, keys(%{$form})));
251 212

  
252
  if ($form->{"remap_parts_id"}) {
253
    $new_item->{"parts_id"} = $new_item->{"id"};
254
    delete($new_item->{"id"});
213
  foreach (grep /$re/, keys %{ $form }) {
214
    my $new_key           =  $_;
215
    $new_key              =~ s/^new_//;
216
    $new_key              =~ s/_\d+$//;
217
    $new_item->{$new_key} =  $form->{$_};
255 218
  }
256
  if ($form->{"remap_partnumber"}) {
257
    $new_item->{"partnumber"} = $new_item->{"number"};
258
    delete($new_item->{"number"});
219

  
220
  if ($form->{remap_parts_id}) {
221
    $new_item->{parts_id} = $new_item->{id};
222
    delete $new_item->{id};
259 223
  }
260 224

  
261
  my $callback_sub = $form->{"callback_sub"};
225
  if ($form->{remap_partnumber}) {
226
    $new_item->{partnumber} = $new_item->{number};
227
    delete $new_item->{number};
228
  }
262 229

  
263
  restore_form($form->{"old_form"});
230
  my $callback_sub = $form->{callback_sub};
231

  
232
  restore_form($form->{old_form});
264 233

  
265 234
  call_sub($callback_sub, $new_item);
266 235

  
......
270 239
sub part_selection_internal {
271 240
  $lxdebug->enter_sub();
272 241

  
273
  $order_by = "description";
274
  $order_by = $form->{"order_by"} if (defined($form->{"order_by"}));
242
  $order_by  = "description";
243
  $order_by  = $form->{"order_by"} if (defined($form->{"order_by"}));
275 244
  $order_dir = 1;
276 245
  $order_dir = $form->{"order_dir"} if (defined($form->{"order_dir"}));
277 246

  
247
  %options   = map { $_ => 1 } split m/:/, $form->{options};
248

  
249
  map { $form->{$_} = 1 if ($options{$_}) } qw(no_services no_assemblies stockable);
250

  
278 251
  $parts = Common->retrieve_parts(\%myconfig, $form, $order_by, $order_dir);
279 252
  map({ $parts->[$_]->{"selected"} = $_ ? 0 : 1; } (0..$#{$parts}));
280 253
  if (0 == scalar(@{$parts})) {
......
285 258

  
286 259
  my $callback = "$form->{script}?action=part_selection_internal&";
287 260
  map({ $callback .= "$_=" . $form->escape($form->{$_}) . "&" }
288
      (qw(login password partnumber description input_partnumber input_description input_partsid), grep({ /^[fl]_/ } keys %$form)));
261
      (qw(partnumber description input_partnumber input_description input_partsid), grep({ /^[fl]_/ } keys %$form)));
289 262

  
290 263
  my @header_sort = qw(partnumber description);
291 264
  my %header_title = ( "partnumber" => $locale->text("Part Number"),
......
301 274

  
302 275
  $form->{"title"} = $locale->text("Select a part");
303 276
  $form->header();
304
  print($form->parse_html_template("generic/part_selection", { "HEADER" => \@header,
305
                                                               "PARTS" => $parts,
306
                                                               "onload" => $onload }));
277
  print $form->parse_html_template("generic/part_selection", { "HEADER" => \@header,
278
                                                               "PARTS"  => $parts,
279
                                                               "onload" => $onload });
307 280

  
308 281
  $lxdebug->leave_sub();
309 282
}
310 283

  
284
# -------------------------------------------------------------------------
285

  
311 286
sub project_selection_internal {
312 287
  $lxdebug->enter_sub();
313 288

  
314
  $order_by = "description";
315
  $order_by = $form->{"order_by"} if (defined($form->{"order_by"}));
316
  $order_dir = 1;
317
  $order_dir = $form->{"order_dir"} if (defined($form->{"order_dir"}));
289
  $auth->check_right($form->{login}, 'project_edit');
318 290

  
319
  $projects = Common->retrieve_projects(\%myconfig, $form, $order_by, $order_dir);
320
  map({ $projects->[$_]->{"selected"} = $_ ? 0 : 1; } (0..$#{$projects}));
321
  if (0 == scalar(@{$projects})) {
322
    $form->show_generic_information($locale->text("No project was found matching the search parameters."));
323
  } elsif (1 == scalar(@{$projects})) {
291
  my %valid_order_by_fields = ('description' => 1, 'projectnumber' => 1);
292

  
293
  $order_by  = "description";
294
  $order_by  = $form->{order_by} if ($valid_order_by_fields{$form->{order_by}});
295
  $order_dir = !defined $form->{order_dir} ? 1 : $form->{order_dir} ? 1 : 0;
296

  
297
  $projects  = Common->retrieve_projects(\%myconfig, $form, $order_by, $order_dir);
298

  
299
  if (1 == scalar @{ $projects }) {
324 300
    $onload = "project_selected('1')";
325 301
  }
326 302

  
327
  my $callback = "$form->{script}?action=project_selection_internal&";
328
  map({ $callback .= "$_=" . $form->escape($form->{$_}) . "&" }
329
      (qw(login password projectnumber description input_projectnumber input_description input_project_id), grep({ /^[fl]_/ } keys %$form)));
303
  my $callback = build_std_url('action=project_selection_internal', qw(projectnumber description input_projectnumber input_description input_project_id),
304
                               grep { /^[fl]_/ } keys %{ $form });
330 305

  
331
  my @header_sort = qw(projectnumber description);
306
  my @header_sort  = qw(projectnumber description);
332 307
  my %header_title = ( "projectnumber" => $locale->text("Project Number"),
333
                       "description" => $locale->text("Project description"),
308
                       "description"   => $locale->text("Project description"),
334 309
                       );
335 310

  
336 311
  my @header =
337 312
    map(+{ "column_title" => $header_title{$_},
338
           "column" => $_,
339
           "callback" => $callback . "order_by=${_}&order_dir=" . ($order_by eq $_ ? 1 - $order_dir : $order_dir),
313
           "column"       => $_,
314
           "callback"     => $callback . "&order_by=${_}&order_dir=" . ($order_by eq $_ ? 1 - $order_dir : $order_dir),
340 315
         },
341 316
        @header_sort);
342 317

  
343
  $form->{"title"} = $locale->text("Select a project");
318
  $form->{title} = $locale->text("Select a project");
344 319
  $form->header();
345
  print($form->parse_html_template("generic/project_selection", { "HEADER" => \@header,
320
  print $form->parse_html_template("generic/project_selection", { "HEADER"   => \@header,
346 321
                                                                  "PROJECTS" => $projects,
347
                                                                  "onload" => $onload }));
322
                                                                  "onload"   => $onload });
323

  
324
  $lxdebug->leave_sub();
325
}
326

  
327
sub new_project {
328
  $lxdebug->enter_sub();
329

  
330
  delete @{$form}{qw(action login password)};
331

  
332
  my $callback = build_std_url('action=project_created', grep { '' eq ref $form->{$_} } keys %{ $form });
333

  
334
  my $argv = "action=add&type=project&callback=" . E($callback);
335

  
336
  exec("perl", "pe.pl", $argv);
337
}
338

  
339
sub project_created {
340
  $lxdebug->enter_sub();
341

  
342
  $form->{title} = $locale->text("Select a project");
343
  $form->header();
344

  
345
  my $args = {
346
    'PROJECTS' => [ { map { $_ => $form->{"new_$_"} } qw(id projectnumber description) } ],
347
    'HEADER'   => [],
348
    'onload'   => "project_selected('1')",
349
  };
350

  
351
  print $form->parse_html_template("generic/project_selection", $args);
348 352

  
349 353
  $lxdebug->leave_sub();
350 354
}
351 355

  
356
sub project_selection_check {
357
  $lxdebug->enter_sub();
358

  
359
  my ($id_field, $number_field, $description_field, $project_selected_nextsub, $prefix) = @_;
360

  
361
  $prefix = "f_" unless defined($prefix);
362

  
363
  if (!$form->{"${prefix}${number_field}"} &&
364
      (!$description_field || !$form->{"${prefix}${description_field}"})) {
365
    delete $form->{"${prefix}${id_field}"};
366
    delete $form->{"${prefix}old_${number_field}"};
367
    delete $form->{"${prefix}old_${description_field}"} if ($description_field);
368

  
369
    $lxdebug->leave_sub();
370
    return 1;
371
  }
372

  
373
  if (($form->{"${prefix}${number_field}"}      eq $form->{"${prefix}old_${number_field}"}) &&
374
      (!$description_field ||
375
       (($form->{"${prefix}${description_field}"} eq $form->{"${prefix}old_${description_field}"})))) {
376
    $lxdebug->leave_sub();
377
    return 1;
378
  }
379

  
380
  my $old_form = save_form();
381

  
382
  $form->{projectnumber} = $form->{"${prefix}${number_field}"};
383
  $form->{full_search}   = 1;
384

  
385
  if ($description_field) {
386
    $form->{description} = $form->{"${prefix}${description_field}"};
387
  } else {
388
    delete $form->{description};
389
  }
390

  
391
  my $projects = Common->retrieve_projects(\%myconfig, $form, "projectnumber", 1);
392
  restore_form($old_form);
393

  
394
  if (0 == scalar @{$projects}) {
395
    $form->error(sprintf($locale->text("There is no project whose project number matches '%s'."), $form->{"${prefix}${number_field}"}));
396

  
397
    $lxdebug->leave_sub();
398
    return 0;
399
  }
400

  
401
  if (1 != scalar(@{$projects})) {
402
    $form->{project_selected_nextsub}        = $project_selected_nextsub;
403
    $form->{check_project_id_field}          = $id_field;
404
    $form->{check_project_number_field}      = $number_field;
405
    $form->{check_project_description_field} = $description_field;
406

  
407
    project_selection("project_selection_selected", $prefix, @{ $projects });
408

  
409
    $lxdebug->leave_sub();
410
    return 0;
411
  }
412

  
413
  $form->{"${prefix}${id_field}"}         = $projects->[0]->{id};
414
  $form->{"${prefix}${number_field}"}     = $projects->[0]->{projectnumber};
415
  $form->{"${prefix}old_${number_field}"} = $projects->[0]->{projectnumber};
416

  
417
  if ($description_field) {
418
    $form->{"${prefix}${description_field}"}     = $projects->[0]->{description};
419
    $form->{"${prefix}old_${description_field}"} = $projects->[0]->{description};
420
  }
421

  
422
  $lxdebug->leave_sub();
423

  
424
  return 1;
425
}
426

  
427
sub project_selection {
428
  $lxdebug->enter_sub();
429

  
430
  my ($callback_sub, $prefix, @projects) = @_;
431

  
432
  if (0 == scalar @projects) {
433
    my $old_form = save_form();
434
    map { delete($form->{$_}); } qw(projectnumber description);
435

  
436
    @projects = @{ Common->retrieve_projects(\%myconfig, $form, "projectnumber", 1) };
437

  
438
    restore_form($old_form);
439
  }
440

  
441
  $form->header();
442
  print $form->parse_html_template("generic/select_project",
443
                                   { "PROJECTS"     => \@projects,
444
                                     "old_form"     => save_form(qw(login password)),
445
                                     "title"        => $locale->text("Select an project"),
446
                                     "nextsub"      => "project_selection_step2",
447
                                     "prefix"       => $prefix,
448
                                     "callback_sub" => $callback_sub });
449

  
450
  $lxdebug->leave_sub();
451
}
452

  
453
sub project_selection_step2 {
454
  $lxdebug->enter_sub();
455

  
456
  my ($new_id, $new_name, $callback_sub);
457

  
458
  my $new_id          = $form->{"new_id_"          . $form->{selection}};
459
  my $new_number      = $form->{"new_number_"      . $form->{selection}};
460
  my $new_description = $form->{"new_description_" . $form->{selection}};
461
  my $callback_sub    = $form->{callback_sub};
462
  my $prefix          = $form->{prefix};
463

  
464
  restore_form($form->{old_form}, 0, qw(login password));
465
  delete $form->{header};
466

  
467
  call_sub($callback_sub, $new_id, $new_number, $new_description, $prefix);
468

  
469
  $lxdebug->leave_sub();
470
}
471

  
472
sub project_selection_selected {
473
  $lxdebug->enter_sub();
474

  
475
  my ($new_id, $new_number, $new_description, $prefix) = @_;
476

  
477
  my ($id_field, $number_field, $description_field)    = ($form->{check_project_id_field}, $form->{check_project_number_field}, $form->{check_project_description_field});
478

  
479
  map { delete $form->{"check_project_${_}_field"} } qw(id number description);
480

  
481
  $form->{"${prefix}${id_field}"}         = $new_id;
482
  $form->{"${prefix}${number_field}"}     = $new_number;
483
  $form->{"${prefix}old_${number_field}"} = $new_number;
484

  
485
  if ($description_field) {
486
    $form->{"${prefix}${description_field}"}     = $new_description;
487
    $form->{"${prefix}old_${description_field}"} = $new_description;
488
  }
489

  
490
  call_sub($form->{project_selected_nextsub});
491

  
492
  $lxdebug->leave_sub();
493
}
494

  
495
# -------------------------------------------------------------------------
496

  
352 497
sub employee_selection_internal {
353 498
  $lxdebug->enter_sub();
354 499

  
......
367 512

  
368 513
  my $callback = "$form->{script}?action=employee_selection_internal&";
369 514
  map({ $callback .= "$_=" . $form->escape($form->{$_}) . "&" }
370
      (qw(login password name input_name input_id), grep({ /^[fl]_/ } keys %$form)));
515
      (qw(name input_name input_id), grep({ /^[fl]_/ } keys %$form)));
371 516

  
372 517
  my @header_sort = qw(name);
373 518
  my %header_title = ( "name" => $locale->text("Name"),
......
389 534
  $lxdebug->leave_sub();
390 535
}
391 536

  
537
# -------------------------------------------------------------------------
538

  
392 539
sub delivery_customer_selection {
393 540
  $lxdebug->enter_sub();
394 541

  
......
407 554

  
408 555
  my $callback = "$form->{script}?action=delivery_customer_selection&";
409 556
  map({ $callback .= "$_=" . $form->escape($form->{$_}) . "&" }
410
      (qw(login password name input_name input_id), grep({ /^[fl]_/ } keys %$form)));
557
      (qw(name input_name input_id), grep({ /^[fl]_/ } keys %$form)));
411 558

  
412 559
  my @header_sort = qw(name customernumber address);
413 560
  my %header_title = ( "name" => $locale->text("Name"),
......
431 578
  $lxdebug->leave_sub();
432 579
}
433 580

  
581
# -------------------------------------------------------------------------
582

  
434 583
sub vendor_selection {
435 584
  $lxdebug->enter_sub();
436 585

  
......
449 598

  
450 599
  my $callback = "$form->{script}?action=vendor_selection&";
451 600
  map({ $callback .= "$_=" . $form->escape($form->{$_}) . "&" }
452
      (qw(login password name input_name input_id), grep({ /^[fl]_/ } keys %$form)));
601
      (qw(name input_name input_id), grep({ /^[fl]_/ } keys %$form)));
453 602

  
454 603
  my @header_sort = qw(name customernumber address);
455 604
  my %header_title = ( "name" => $locale->text("Name"),
......
473 622
  $lxdebug->leave_sub();
474 623
}
475 624

  
625
# -------------------------------------------------------------------------
626

  
476 627
sub calculate_qty {
477 628
  $lxdebug->enter_sub();
478 629

  
......
484 635
  my ($variable_string, $formel) = split /###/,$form->{formel};
485 636

  
486 637

  
487
  split /;/, $variable_string;
638
  split m/;/, $variable_string;
488 639
  foreach $item (@_) {
489 640
    my($name, $valueunit) = split /=/,$item;
490 641
    my($value, $unit) = split / /, $valueunit;
......
509 660
           "column" => $_,
510 661
         },
511 662
        @header_sort);
512
  $form->{formel} = $formel; 
663
  $form->{formel} = $formel;
513 664
  $form->{"title"} = $locale->text("Please enter values");
514 665
  $form->header();
515 666
  print($form->parse_html_template("generic/calculate_qty", { "HEADER"    => \@header,
......
519 670
  $lxdebug->leave_sub();
520 671
}
521 672

  
673
# -------------------------------------------------------------------------
674

  
522 675
sub set_longdescription {
523 676
  $lxdebug->enter_sub();
524 677

  
......
529 682
  $lxdebug->leave_sub();
530 683
}
531 684

  
685
# -------------------------------------------------------------------------
686

  
532 687
sub H {
533 688
  return $form->quote_html($_[0]);
534 689
}
......
618 773
  $lxdebug->leave_sub();
619 774
}
620 775

  
776
# -------------------------------------------------------------------------
777

  
621 778
sub show_history {
622 779
	$lxdebug->enter_sub();
623 780
	my $dbh = $form->dbconnect(\%myconfig);
624 781
	my ($sort, $sortby) = split(/\-\-/, $form->{order});
625 782
  $sort =~ s/.*\.(.*)/$1/;
626
  
783

  
627 784
	$form->{title} = $locale->text("History");
628 785
    $form->header();
629 786
    print $form->parse_html_template( "common/show_history", {
......
632 789
      uc($sort) => 1,
633 790
      uc($sort)."BY" => $sortby
634 791
    	} );
635
	
792

  
636 793
	$dbh->disconnect();
637
	$lxdebug->leave_sub();	
794
	$lxdebug->leave_sub();
638 795
}
639 796

  
797
# -------------------------------------------------------------------------
798

  
640 799
sub call_sub {
641 800
  $lxdebug->enter_sub();
642 801

  
......
657 816
  $lxdebug->leave_sub();
658 817
}
659 818

  
819
# -------------------------------------------------------------------------
820

  
660 821
sub show_vc_details {
661 822
	$lxdebug->enter_sub();
662 823

  
......
676 837
	$lxdebug->leave_sub();
677 838
}
678 839

  
840
# -------------------------------------------------------------------------
841

  
842
sub retrieve_partunits {
843
  $lxdebug->enter_sub();
844

  
845
  my @part_ids = grep { $_ } map { $form->{"id_${_}"} } (1..$form->{rowcount});
846

  
847
  if (@part_ids) {
848
    my %partunits = IO->retrieve_partunits('part_ids' => \@part_ids);
849

  
850
    foreach my $i (1..$form->{rowcount}) {
851
      next unless ($form->{"id_${i}"});
852
      $form->{"partunit_${i}"} = $partunits{$form->{"id_${i}"}};
853
    }
854
  }
855

  
856
  $lxdebug->leave_sub();
857
}
858

  
859
# -------------------------------------------------------------------------
860

  
679 861
sub mark_as_paid_common {
680 862
  $lxdebug->enter_sub();
681
  use SL::DBUtils;
863

  
682 864
  my ($myconfig, $db_name) = @_;
683 865

  
684 866
  if($form->{mark_as_paid}) {
......
687 869
    do_query($form, $dbh, $query, $form->{id});
688 870
    $dbh->commit();
689 871
    $form->redirect($locale->text("Marked as paid"));
690
}
691
  else {
692
    my $referer  =  $ENV{HTTP_REFERER};
693
    my $login    =  $form->escape($form->{login});
694
    my $password =  $form->escape($form->{password});
695
    my $id       =  $form->escape($form->{id});
696
    $referer     =~ s/^(.*)action\=.*\&(.*)$/$1action\=mark_as_paid\&mark_as_paid\=1\&login\=$login\&password\=$password\&id\=$id\&$2/;
872

  
873
  } else {
874
    my $referer = $ENV{HTTP_REFERER};
875
    $referer =~ s/^(.*)action\=.*\&(.*)$/$1action\=mark_as_paid\&mark_as_paid\=1\&id\=$form->{id}\&$2/;
697 876
    $form->header();
698 877
    print qq|<body>|;
699 878
    print qq|<p><b>|.$locale->text('Mark as paid?').qq|</b></p>|;
700 879
    print qq|<input type="button" value="|.$locale->text('yes').qq|" onclick="document.location.href='|.$referer.qq|'">&nbsp;|;
701 880
    print qq|<input type="button" value="|.$locale->text('no').qq|" onclick="javascript:history.back();">|;
702 881
    print qq|</body></html>|;
703
}
704
  
882
  }
883

  
705 884
  $lxdebug->leave_sub();
706 885
}
707 886

  

Auch abrufbar als: Unified diff