Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 9257ca9a

Von Sven Schöling vor etwa 15 Jahren hinzugefügt

  • ID 9257ca9ac3305509e73b05db383a9539282dd878
  • Vorgänger 3314d7c2
  • Nachfolger 429203bf

common strict

Unterschiede anzeigen:

bin/mozilla/common.pl
14 14
use SL::Form;
15 15
use SL::MoreCommon;
16 16

  
17
use strict;
18

  
17 19
sub build_std_url {
18
  $lxdebug->enter_sub(2);
20
  $main::lxdebug->enter_sub(2);
21

  
22
  my $form     = $main::form;
19 23

  
20 24
  my $script = $form->{script};
21 25

  
......
40 44

  
41 45
  my $url = "${script}?" . join('&', @parts);
42 46

  
43
  $lxdebug->leave_sub(2);
47
  $main::lxdebug->leave_sub(2);
44 48

  
45 49
  return $url;
46 50
}
......
48 52
# -------------------------------------------------------------------------
49 53

  
50 54
sub select_part {
51
  $lxdebug->enter_sub();
55
  $main::lxdebug->enter_sub();
52 56

  
53 57
  my ($callback_sub, @parts) = @_;
54 58

  
59
  my $form     = $main::form;
60
  my $locale   = $main::locale;
61

  
55 62
  my $remap_parts_id = 0;
56 63
  if (defined($parts[0]->{parts_id}) && !defined($parts[0]->{id})) {
57 64
    $remap_parts_id = 1;
......
89 96
                                     "remap_parts_id"   => $remap_parts_id,
90 97
                                     "remap_partnumber" => $remap_partnumber });
91 98

  
92
  $lxdebug->leave_sub();
99
  $main::lxdebug->leave_sub();
93 100
}
94 101

  
95 102
sub select_part_internal {
96
  $lxdebug->enter_sub();
103
  $main::lxdebug->enter_sub();
104

  
105
  my $form     = $main::form;
97 106

  
98 107
  my ($new_item, $callback_sub);
99 108

  
......
116 125
    delete $new_item->{number};
117 126
  }
118 127

  
119
  my $callback_sub = $form->{callback_sub};
128
  $callback_sub = $form->{callback_sub};
120 129

  
121 130
  restore_form($form->{old_form});
122 131

  
123 132
  call_sub($callback_sub, $new_item);
124 133

  
125
  $lxdebug->leave_sub();
134
  $main::lxdebug->leave_sub();
126 135
}
127 136

  
128 137
sub part_selection_internal {
129
  $lxdebug->enter_sub();
138
  $main::lxdebug->enter_sub();
139

  
140
  my $form     = $main::form;
141
  my %myconfig = %main::myconfig;
142
  my $locale   = $main::locale;
130 143

  
131
  $order_by  = "description";
144
  my $order_by  = "description";
132 145
  $order_by  = $form->{"order_by"} if (defined($form->{"order_by"}));
133
  $order_dir = 1;
146
  my $order_dir = 1;
134 147
  $order_dir = $form->{"order_dir"} if (defined($form->{"order_dir"}));
135 148

  
136 149
  my %options;
......
147 160

  
148 161
  map { $form->{$_} = $options{$_} if ($options{$_}) } qw(no_services no_assemblies assemblies click_button);
149 162

  
150
  $parts = Common->retrieve_parts(\%myconfig, $form, $order_by, $order_dir);
163
  my $parts = Common->retrieve_parts(\%myconfig, $form, $order_by, $order_dir);
164
  my $onload;
151 165

  
152 166
  if (0 == scalar(@{$parts})) {
153 167
    $form->show_generic_information($locale->text("No part was found matching the search parameters."));
......
180 194
                                                               "PARTS"  => $parts,
181 195
                                                               "onload" => $onload });
182 196

  
183
  $lxdebug->leave_sub();
197
  $main::lxdebug->leave_sub();
184 198
}
185 199

  
186 200
# -------------------------------------------------------------------------
187 201

  
188 202
sub delivery_customer_selection {
189
  $lxdebug->enter_sub();
203
  $main::lxdebug->enter_sub();
204

  
205
  my $form     = $main::form;
206
  my %myconfig = %main::myconfig;
207
  my $locale   = $main::locale;
190 208

  
191
  $order_by = "name";
209
  my $order_by = "name";
192 210
  $order_by = $form->{"order_by"} if (defined($form->{"order_by"}));
193
  $order_dir = 1;
211
  my $order_dir = 1;
194 212
  $order_dir = $form->{"order_dir"} if (defined($form->{"order_dir"}));
195 213

  
196
  $delivery = Common->retrieve_delivery_customer(\%myconfig, $form, $order_by, $order_dir);
214
  my $delivery = Common->retrieve_delivery_customer(\%myconfig, $form, $order_by, $order_dir);
197 215
  map({ $delivery->[$_]->{"selected"} = $_ ? 0 : 1; } (0..$#{$delivery}));
216

  
217
  my $onload;
198 218
  if (0 == scalar(@{$delivery})) {
199 219
    $form->show_generic_information($locale->text("No Customer was found matching the search parameters."));
200 220
  } elsif (1 == scalar(@{$delivery})) {
......
224 244
                                                                         "DELIVERY" => $delivery,
225 245
                                                                         "onload"   => $onload });
226 246

  
227
  $lxdebug->leave_sub();
247
  $main::lxdebug->leave_sub();
228 248
}
229 249

  
230 250
# -------------------------------------------------------------------------
231 251

  
232 252
sub vendor_selection {
233
  $lxdebug->enter_sub();
253
  $main::lxdebug->enter_sub();
254

  
255
  my $form     = $main::form;
256
  my %myconfig = %main::myconfig;
257
  my $locale   = $main::locale;
234 258

  
235
  $order_by = "name";
259
  my $order_by = "name";
236 260
  $order_by = $form->{"order_by"} if (defined($form->{"order_by"}));
237
  $order_dir = 1;
261
  my $order_dir = 1;
238 262
  $order_dir = $form->{"order_dir"} if (defined($form->{"order_dir"}));
239 263

  
240
  $vendor = Common->retrieve_vendor(\%myconfig, $form, $order_by, $order_dir);
264
  my $vendor = Common->retrieve_vendor(\%myconfig, $form, $order_by, $order_dir);
241 265
  map({ $vendor->[$_]->{"selected"} = $_ ? 0 : 1; } (0..$#{$vendor}));
266

  
267
  my $onload;
242 268
  if (0 == scalar(@{$vendor})) {
243 269
    $form->show_generic_information($locale->text("No Vendor was found matching the search parameters."));
244 270
  } elsif (1 == scalar(@{$vendor})) {
......
268 294
                                                              "VENDOR" => $vendor,
269 295
                                                              "onload" => $onload });
270 296

  
271
  $lxdebug->leave_sub();
297
  $main::lxdebug->leave_sub();
272 298
}
273 299

  
274 300
# -------------------------------------------------------------------------
275 301

  
276 302
sub calculate_qty {
277
  $lxdebug->enter_sub();
303
  $main::lxdebug->enter_sub();
304

  
305
  my $form     = $main::form;
306
  my $locale   = $main::locale;
278 307

  
279 308
  $form->{formel} =~ s/\r\n//g;
280 309

  
281 310
  my ($variable_string, $formel) = split /###/,$form->{formel};
311
  my @variable;
312
  my $onload; # note! this sub is mostly called over a javascript invocation, and it's unlikey that onload is set.
282 313

  
283
  foreach $item (split m/;/, $variable_string) {
314
  foreach my $item (split m/;/, $variable_string) {
284 315
    next unless $item =~ m/^ \s* (\w+) \s* = \s* (\w+) \s* (\w+) \s* $/x;
285 316
    push @variable, {
286 317
      description => $1,
......
307 338
                                                              "VARIABLES" => \@variable,
308 339
                                                              "onload"    => $onload });
309 340

  
310
  $lxdebug->leave_sub();
341
  $main::lxdebug->leave_sub();
311 342
}
312 343

  
313 344
# -------------------------------------------------------------------------
314 345

  
315 346
sub set_longdescription {
316
  $lxdebug->enter_sub();
347
  $main::lxdebug->enter_sub();
348

  
349
  my $form     = $main::form;
350
  my $locale   = $main::locale;
317 351

  
318 352
  $form->{title} = $locale->text("Enter longdescription");
319 353
  $form->header();
320 354
  print $form->parse_html_template("generic/set_longdescription");
321 355

  
322
  $lxdebug->leave_sub();
356
  $main::lxdebug->leave_sub();
323 357
}
324 358

  
325 359
# -------------------------------------------------------------------------
326 360

  
327 361
sub H {
328
  return $locale->quote_special_chars('HTML', $_[0]);
362
  return $main::locale->quote_special_chars('HTML', $_[0]);
329 363
}
330 364

  
331 365
sub Q {
332
  return $locale->quote_special_chars('URL@HTML', $_[0]);
366
  return $main::locale->quote_special_chars('URL@HTML', $_[0]);
333 367
}
334 368

  
335 369
sub E {
336
  return $form->escape($_[0]);
370
  return $main::form->escape($_[0]);
337 371
}
338 372

  
339 373
sub NTI {
......
344 378
}
345 379

  
346 380
sub format_dates {
347
  $lxdebug->enter_sub();
381
  $main::lxdebug->enter_sub();
348 382

  
349 383
  my ($dateformat, $longformat, @indices) = @_;
350 384

  
385
  my $form     = $main::form;
386
  my %myconfig = %main::myconfig;
387
  my $locale   = $main::locale;
388

  
351 389
  $dateformat = $myconfig{"dateformat"} unless ($dateformat);
352 390

  
353 391
  foreach my $idx (@indices) {
......
374 412
    }
375 413
  }
376 414

  
377
  $lxdebug->leave_sub();
415
  $main::lxdebug->leave_sub();
378 416
}
379 417

  
380 418
sub reformat_numbers {
381
  $lxdebug->enter_sub();
419
  $main::lxdebug->enter_sub();
382 420

  
383 421
  my ($numberformat, $places, @indices) = @_;
384 422

  
385
  return $lxdebug->leave_sub()
423
  my $form     = $main::form;
424
  my %myconfig = %main::myconfig;
425

  
426
  return $main::lxdebug->leave_sub()
386 427
    if (!$numberformat || ($numberformat eq $myconfig{"numberformat"}));
387 428

  
388 429
  foreach my $idx (@indices) {
......
430 471

  
431 472
  $myconfig{"numberformat"} = $saved_numberformat;
432 473

  
433
  $lxdebug->leave_sub();
474
  $main::lxdebug->leave_sub();
434 475
}
435 476

  
436 477
# -------------------------------------------------------------------------
437 478

  
438 479
sub show_history {
439
	$lxdebug->enter_sub();
480
	$main::lxdebug->enter_sub();
481

  
482
  my $form     = $main::form;
483
  my %myconfig = %main::myconfig;
484
  my $locale   = $main::locale;
485

  
440 486
	my $dbh = $form->dbconnect(\%myconfig);
441 487
	my ($sort, $sortby) = split(/\-\-/, $form->{order});
442 488
  $sort =~ s/.*\.(.*)/$1/;
......
451 497
    	} );
452 498

  
453 499
	$dbh->disconnect();
454
	$lxdebug->leave_sub();
500
	$main::lxdebug->leave_sub();
455 501
}
456 502

  
457 503
# -------------------------------------------------------------------------
458 504

  
459 505
sub call_sub {
460
  $lxdebug->enter_sub();
506
  $main::lxdebug->enter_sub();
461 507

  
462 508
  my $name = shift;
463 509

  
510
  my $form     = $main::form;
511
  my $locale   = $main::locale;
512

  
464 513
  if (!$name) {
465 514
    $form->error($locale->text("Trying to call a sub without a name"));
466 515
  }
......
471 520
    $form->error(sprintf($locale->text("Attempt to call an undefined sub named '%s'"), $name));
472 521
  }
473 522

  
474
  &{ $name }(@_);
523
  {
524
    no strict "refs";
525
    &{ $name }(@_);
526
  }
475 527

  
476
  $lxdebug->leave_sub();
528
  $main::lxdebug->leave_sub();
477 529
}
478 530

  
479 531
# -------------------------------------------------------------------------
480 532

  
481 533
sub show_vc_details {
482
	$lxdebug->enter_sub();
534
	$main::lxdebug->enter_sub();
535

  
536
  my $form     = $main::form;
537
  my %myconfig = %main::myconfig;
538
  my $locale   = $main::locale;
483 539

  
484 540
  $form->{vc} = $form->{vc} eq "customer" ? "customer" : "vendor";
485 541
  $form->isblank("vc_id",
......
494 550
  $form->header();
495 551
  print $form->parse_html_template("common/show_vc_details", { "is_customer" => $form->{vc} eq "customer" });
496 552

  
497
	$lxdebug->leave_sub();
553
	$main::lxdebug->leave_sub();
498 554
}
499 555

  
500 556
# -------------------------------------------------------------------------
501 557

  
502 558
sub retrieve_partunits {
503
  $lxdebug->enter_sub();
559
  $main::lxdebug->enter_sub();
560

  
561
  my $form     = $main::form;
504 562

  
505 563
  my @part_ids = grep { $_ } map { $form->{"id_${_}"} } (1..$form->{rowcount});
506 564

  
......
513 571
    }
514 572
  }
515 573

  
516
  $lxdebug->leave_sub();
574
  $main::lxdebug->leave_sub();
517 575
}
518 576

  
519 577
# -------------------------------------------------------------------------
520 578

  
521 579
sub mark_as_paid_common {
522
  $lxdebug->enter_sub();
580
  $main::lxdebug->enter_sub();
523 581

  
524 582
  my ($myconfig, $db_name) = @_;
525 583

  
584
  my $form     = $main::form;
585
  my $locale   = $main::locale;
586

  
526 587
  if($form->{mark_as_paid}) {
527 588
    my $dbh ||= $form->get_standard_dbh($myconfig);
528 589
    my $query = qq|UPDATE $db_name SET paid = amount WHERE id = ?|;
......
532 593

  
533 594
  } else {
534 595
    my $referer = $ENV{HTTP_REFERER};
596
    my $script;
597
    my $callback;
535 598
    if ($referer =~ /action/) {
536 599
      $referer =~ /^(.*)\?action\=[^\&]*(\&.*)$/;
537 600
      $script = $1;
......
549 612
    print qq|</body></html>|;
550 613
  }
551 614

  
552
  $lxdebug->leave_sub();
615
  $main::lxdebug->leave_sub();
553 616
}
554 617

  
555 618
sub cov_selection_internal {
556
  $lxdebug->enter_sub();
619
  $main::lxdebug->enter_sub();
557 620

  
558
  $order_by = "name";
621
  my $form     = $main::form;
622
  my %myconfig = %main::myconfig;
623
  my $locale   = $main::locale;
624

  
625
  my $order_by = "name";
559 626
  $order_by = $form->{"order_by"} if (defined($form->{"order_by"}));
560
  $order_dir = 1;
627
  my $order_dir = 1;
561 628
  $order_dir = $form->{"order_dir"} if (defined($form->{"order_dir"}));
562 629

  
563 630
  my $type = $form->{"is_vendor"} ? $locale->text("vendor") : $locale->text("customer");
564 631

  
565
  $covs = Common->retrieve_customers_or_vendors(\%myconfig, $form, $order_by, $order_dir, $form->{"is_vendor"}, $form->{"allow_both"});
632
  my $covs = Common->retrieve_customers_or_vendors(\%myconfig, $form, $order_by, $order_dir, $form->{"is_vendor"}, $form->{"allow_both"});
566 633
  map({ $covs->[$_]->{"selected"} = $_ ? 0 : 1; } (0..$#{$covs}));
634

  
635
  my $onload;
567 636
  if (0 == scalar(@{$covs})) {
568 637
    $form->show_generic_information(sprintf($locale->text("No %s was found matching the search parameters."), $type));
569 638
  } elsif (1 == scalar(@{$covs})) {
......
602 671
                                                              "COVS" => $covs,
603 672
                                                              "onload" => $onload }));
604 673

  
605
  $lxdebug->leave_sub();
674
  $main::lxdebug->leave_sub();
606 675
}
607 676

  
608 677

  
609 678
# Functions to call add routines beneath different reports
610 679

  
611 680
sub sales_invoice {
612
  $lxdebug->enter_sub();
681
  $main::lxdebug->enter_sub();
613 682

  
614
  $auth->assert('invoice_edit');
683
  $main::auth->assert('invoice_edit');
615 684

  
685
  my $form     = $main::form;
686
  my %myconfig = %main::myconfig;
687
  my $locale   = $main::locale;
616 688

  
617 689
  $form->{script} = 'is.pl';
618
  $script         = "is";
690
  my $script      = "is";
619 691
  $form->{type} = "invoice";
620 692
  $locale = new Locale "$myconfig{countrycode}", "$script";
621 693

  
622 694
  require "bin/mozilla/$form->{script}";
623 695
  &add;
624 696

  
625
  $lxdebug->leave_sub();
697
  $main::lxdebug->leave_sub();
626 698
}
627 699

  
628 700
sub ar_transaction {
629
  $lxdebug->enter_sub();
701
  $main::lxdebug->enter_sub();
630 702

  
631
  $auth->assert('general_ledger');
703
  $main::auth->assert('general_ledger');
632 704

  
705
  my $form     = $main::form;
706
  my %myconfig = %main::myconfig;
707
  my $locale   = $main::locale;
633 708

  
634 709
  $form->{script} = 'ar.pl';
635
  $script         = "ar";
710
  my $script      = "ar";
636 711
  $locale = new Locale "$myconfig{countrycode}", "$script";
637 712

  
638 713
  require "bin/mozilla/$form->{script}";
639 714
  &add;
640 715

  
641
  $lxdebug->leave_sub();
716
  $main::lxdebug->leave_sub();
642 717
}
643 718

  
644 719
sub vendor_invoice {
645
  $lxdebug->enter_sub();
720
  $main::lxdebug->enter_sub();
646 721

  
647
  $auth->assert('invoice_edit');
722
  $main::auth->assert('invoice_edit');
648 723

  
724
  my $form     = $main::form;
725
  my %myconfig = %main::myconfig;
726
  my $locale   = $main::locale;
649 727

  
650 728
  $form->{script} = 'ir.pl';
651
  $script         = "ir";
729
  my $script      = "ir";
652 730
  $form->{type} = "invoice";
653 731
  $locale = new Locale "$myconfig{countrycode}", "$script";
654 732

  
655 733
  require "bin/mozilla/$form->{script}";
656 734
  &add;
657 735

  
658
  $lxdebug->leave_sub();
736
  $main::lxdebug->leave_sub();
659 737
}
660 738

  
661 739
sub ap_transaction {
662
  $lxdebug->enter_sub();
740
  $main::lxdebug->enter_sub();
663 741

  
664
  $auth->assert('general_ledger');
742
  $main::auth->assert('general_ledger');
665 743

  
744
  my $form     = $main::form;
745
  my %myconfig = %main::myconfig;
746
  my $locale   = $main::locale;
666 747

  
667 748
  $form->{script} = 'ap.pl';
668
  $script         = "ap";
749
  my $script      = "ap";
669 750
  $locale = new Locale "$myconfig{countrycode}", "$script";
670 751

  
671 752
  require "bin/mozilla/$form->{script}";
672 753
  &add;
673 754

  
674
  $lxdebug->leave_sub();
755
  $main::lxdebug->leave_sub();
675 756
}
676 757

  
677 758
sub gl_transaction {
678
  $lxdebug->enter_sub();
759
  $main::lxdebug->enter_sub();
679 760

  
680
  $auth->assert('general_ledger');
761
  $main::auth->assert('general_ledger');
681 762

  
763
  my $form     = $main::form;
764
  my %myconfig = %main::myconfig;
765
  my $locale   = $main::locale;
682 766

  
683 767
  $form->{script} = 'gl.pl';
684
  $script         = "gl";
768
  my $script      = "gl";
685 769
  $locale = new Locale "$myconfig{countrycode}", "$script";
686 770

  
687 771
  require "bin/mozilla/$form->{script}";
688 772
  &add;
689 773

  
690
  $lxdebug->leave_sub();
774
  $main::lxdebug->leave_sub();
691 775
}
692 776

  
693 777
1;

Auch abrufbar als: Unified diff