Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 4bdfefd9

Von Cem Aydin vor etwa 1 Jahr hinzugefügt

  • ID 4bdfefd97ed105c41f7940792a512968e4f2ab02
  • Vorgänger e2fa650c

Bereinigung SL/Template/OpenDocument.pm hash keys ohne Anführungszeichen gesetzt, gem. Dok. Style Guide

Unterschiede anzeigen:

SL/Template/OpenDocument.pm
199 199

  
200 200
    } elsif ((substr($text, $pos + 4, 4) eq 'else') && (1 == $depth)) {
201 201
      if (!$var) {
202
        $self->{"error"} = '<%else%> outside of <%if%> / <%ifnot%>.';
202
        $self->{error} = '<%else%> outside of <%if%> / <%ifnot%>.';
203 203
        return undef;
204 204
      }
205 205

  
......
255 255

  
256 256
          ($table_row, $contents) = $self->find_end($contents, length($1));
257 257
          if (!$table_row) {
258
            $self->{"error"} = "Unclosed <\%foreachrow\%>." unless ($self->{"error"});
258
            $self->{error} = "Unclosed <\%foreachrow\%>." unless ($self->{"error"});
259 259
            $main::lxdebug->leave_sub();
260 260
            return undef;
261 261
          }
......
310 310
        substr($contents, 0, $pos_foreach) = "";
311 311

  
312 312
        if ($contents !~ m|^(\&lt;\%foreach (.*?)\%\&gt;)|) {
313
          $self->{"error"} = "Malformed <\%foreach\%>.";
313
          $self->{error} = "Malformed <\%foreach\%>.";
314 314
          $main::lxdebug->leave_sub();
315 315
          return undef;
316 316
        }
......
322 322
        my $block;
323 323
        ($block, $contents) = $self->find_end($contents);
324 324
        if (!$block) {
325
          $self->{"error"} = "Unclosed <\%foreach\%>." unless ($self->{"error"});
325
          $self->{error} = "Unclosed <\%foreach\%>." unless ($self->{error});
326 326
          $main::lxdebug->leave_sub();
327 327
          return undef;
328 328
        }
......
353 353
  my $self = $_[0];
354 354

  
355 355
  local *OUT = $_[1];
356
  my $form = $self->{"form"};
356
  my $form = $self->{form};
357 357

  
358 358
  close(OUT);
359 359

  
360 360
  my $is_qr_bill = $::instance_conf->get_create_qrbill_invoices &&
361 361
                   ($form->{formname} eq 'invoice' ||
362 362
                    $form->{formname} eq 'invoice_for_advance_payment') &&
363
                   $form->{'template_meta'}->{'printer'}->{'template_code'} =~ m/qr/ ?
363
                   $form->{template_meta}->{printer}->{template_code} =~ m/qr/ ?
364 364
                   1 : 0;
365 365

  
366 366
  my $qr_image_path;
......
372 372
  }
373 373

  
374 374
  my $file_name;
375
  if ($form->{"IN"} =~ m|^/|) {
376
    $file_name = $form->{"IN"};
375
  if ($form->{IN} =~ m|^/|) {
376
    $file_name = $form->{IN};
377 377
  } else {
378
    $file_name = $form->{"templates"} . "/" . $form->{"IN"};
378
    $file_name = $form->{templates} . "/" . $form->{IN};
379 379
  }
380 380

  
381 381
  my $zip = Archive::Zip->new();
382 382
  if (Archive::Zip->AZ_OK != $zip->read($file_name)) {
383
    $self->{"error"} = "File not found/is not a OpenDocument file.";
383
    $self->{error} = "File not found/is not a OpenDocument file.";
384 384
    $main::lxdebug->leave_sub();
385 385
    return 0;
386 386
  }
387 387

  
388 388
  my $contents = Encode::decode('utf-8-strict', $zip->contents("content.xml"));
389 389
  if (!$contents) {
390
    $self->{"error"} = "File is not a OpenDocument file.";
390
    $self->{error} = "File is not a OpenDocument file.";
391 391
    $main::lxdebug->leave_sub();
392 392
    return 0;
393 393
  }
......
462 462
    );
463 463
  }
464 464

  
465
  $zip->writeToFileNamed($form->{"tmpfile"}, 1);
465
  $zip->writeToFileNamed($form->{tmpfile}, 1);
466 466

  
467 467
  my $res = 1;
468
  if ($form->{"format"} =~ /pdf/) {
468
  if ($form->{format} =~ /pdf/) {
469 469
    $res = $self->convert_to_pdf();
470 470
  }
471 471

  
......
476 476
sub generate_qr_code {
477 477
  $main::lxdebug->enter_sub();
478 478
  my $self = $_[0];
479
  my $form = $self->{"form"};
479
  my $form = $self->{form};
480 480

  
481 481
  # assemble data for QR-Code
482 482

  
......
485 485
  }
486 486

  
487 487
  my %biller_information = (
488
    'iban' => $form->{qrbill_iban}
488
    iban => $form->{qrbill_iban}
489 489
  );
490 490

  
491 491
  if (!$form->{qrbill_biller_countrycode}) {
492 492
    $::form->error($::locale->text('Error mapping biller countrycode.'));
493 493
  }
494 494
  my %biller_data = (
495
    'address_type' => 'K',
496
    'company' => $::instance_conf->get_company(),
497
    'address_row1' => $::instance_conf->get_address_street1(),
498
    'address_row2' => $::instance_conf->get_address_zipcode() . ' ' . $::instance_conf->get_address_city(),
499
    'countrycode' => $form->{qrbill_biller_countrycode},
495
    address_type => 'K',
496
    company => $::instance_conf->get_company(),
497
    address_row1 => $::instance_conf->get_address_street1(),
498
    address_row2 => $::instance_conf->get_address_zipcode() . ' ' . $::instance_conf->get_address_city(),
499
    countrycode => $form->{qrbill_biller_countrycode},
500 500
  );
501 501

  
502 502
  my ($amount, $amount_formatted);
503
  if ($form->{'qrbill_without_amount'}) {
503
  if ($form->{qrbill_without_amount}) {
504 504
    $amount = '';
505 505
    $amount_formatted = '';
506 506
  } else {
......
514 514
  }
515 515

  
516 516
  my %payment_information = (
517
    'amount' => $amount,
518
    'currency' => $form->{'currency'},
517
    amount => $amount,
518
    currency => $form->{currency},
519 519
  );
520 520

  
521 521
  if (!$form->{qrbill_customer_countrycode}) {
......
523 523
  }
524 524

  
525 525
  my %invoice_recipient_data = (
526
    'address_type' => 'K',
527
    'name' => $form->{billing_address_id} ?
528
              $form->{'billing_address_name'} :
529
              $form->{'name'},
530
    'address_row1' => $form->{billing_address_id} ?
531
                      $form->{'billing_address_street'} :
532
                      $form->{'street'},
533
    'address_row2' => $form->{billing_address_id} ?
534
                      $form->{'billing_address_zipcode'} . ' ' . $form->{'billing_address_city'} :
535
                      $form->{'zipcode'} . ' ' . $form->{'city'},
536
    'countrycode' => $form->{qrbill_customer_countrycode},
526
    address_type => 'K',
527
    name => $form->{billing_address_id} ?
528
              $form->{billing_address_name} :
529
              $form->{name},
530
    address_row1 => $form->{billing_address_id} ?
531
                      $form->{billing_address_street} :
532
                      $form->{street},
533
    address_row2 => $form->{billing_address_id} ?
534
                      $form->{billing_address_zipcode} . ' ' . $form->{billing_address_city} :
535
                      $form->{zipcode} . ' ' . $form->{city},
536
    countrycode => $form->{qrbill_customer_countrycode},
537 537
  );
538 538

  
539 539
  my %ref_nr_data;
540 540
  if ($::instance_conf->get_create_qrbill_invoices == 1) {
541 541
    # fill reference number with zeros when printing preview (before booking)
542
    my $reference_number = $form->{'id'} ? $form->{'qr_reference'} : '0' x 27;
542
    my $reference_number = $form->{id} ? $form->{qr_reference} : '0' x 27;
543 543

  
544 544
    %ref_nr_data = (
545
      'type' => 'QRR',
546
      'ref_number' => $reference_number,
545
      type => 'QRR',
546
      ref_number => $reference_number,
547 547
    );
548 548
    # get ref. number/iban formatted with spaces and set into form for template
549 549
    # processing
550
    $form->{'ref_number'} = $reference_number;
551
    $form->{'ref_number_formatted'} = get_ref_number_formatted($reference_number);
550
    $form->{ref_number} = $reference_number;
551
    $form->{ref_number_formatted} = get_ref_number_formatted($reference_number);
552 552
  } elsif ($::instance_conf->get_create_qrbill_invoices == 2) {
553 553
    %ref_nr_data = (
554
      'type' => 'NON',
555
      'ref_number' => '',
554
      type => 'NON',
555
      ref_number => '',
556 556
    );
557 557
  } else {
558 558
    $::form->error($::locale->text('Error getting QR-Bill type.'));
559 559
  }
560 560

  
561 561
  my %additional_information = (
562
    'unstructured_message' => $form->{'qr_unstructured_message'}
562
    unstructured_message => $form->{qr_unstructured_message}
563 563
  );
564 564

  
565 565
  # set into form for template processing
566
  $form->{'biller_information'} = \%biller_information;
567
  $form->{'biller_data'} = \%biller_data;
568
  $form->{'iban_formatted'} = get_iban_formatted($form->{qrbill_iban});
569
  $form->{'amount_formatted'} = $amount_formatted;
570
  $form->{'unstructured_message'} = $form->{'qr_unstructured_message'};
566
  $form->{biller_information} = \%biller_information;
567
  $form->{biller_data} = \%biller_data;
568
  $form->{iban_formatted} = get_iban_formatted($form->{qrbill_iban});
569
  $form->{amount_formatted} = $amount_formatted;
570
  $form->{unstructured_message} = $form->{qr_unstructured_message};
571 571

  
572 572
  # set outfile
573
  my $outfile = $form->{"tmpdir"} . '/' . 'qr-code.png';
573
  my $outfile = $form->{tmpdir} . '/' . 'qr-code.png';
574 574

  
575 575
  # generate QR-Code Image
576 576
  eval {
......
675 675
  }
676 676

  
677 677
  if (!$res) {
678
    $self->{"error"} = "Conversion from OpenDocument to PDF failed because " .
678
    $self->{error} = "Conversion from OpenDocument to PDF failed because " .
679 679
      "OpenOffice could not be started.";
680 680
  }
681 681

  
......
689 689

  
690 690
  my ($self) = @_;
691 691

  
692
  my $form = $self->{"form"};
692
  my $form = $self->{form};
693 693

  
694
  my $filename = $form->{"tmpfile"};
694
  my $filename = $form->{tmpfile};
695 695
  $filename =~ s/.odt$//;
696 696
  if (substr($filename, 0, 1) ne "/") {
697 697
    $filename = getcwd() . "/${filename}";
698 698
  }
699 699

  
700
  if (substr($self->{"userspath"}, 0, 1) eq "/") {
701
    $ENV{'HOME'} = $self->{"userspath"};
700
  if (substr($self->{userspath}, 0, 1) eq "/") {
701
    $ENV{HOME} = $self->{userspath};
702 702
  } else {
703
    $ENV{'HOME'} = getcwd() . "/" . $self->{"userspath"};
703
    $ENV{HOME} = getcwd() . "/" . $self->{userspath};
704 704
  }
705 705

  
706 706
  my $outdir = dirname($filename);
......
723 723

  
724 724
  my $res = $?;
725 725
  if ((0 == $?) || (-f "${filename}.pdf" && -s "${filename}.pdf")) {
726
    $form->{"tmpfile"} =~ s/odt$/pdf/;
726
    $form->{tmpfile} =~ s/odt$/pdf/;
727 727

  
728 728
    unlink($filename . ".odt");
729 729

  
......
733 733
  }
734 734

  
735 735
  unlink($filename . ".odt", $filename . ".pdf");
736
  $self->{"error"} = "Conversion from OpenDocument to PDF failed. " .
736
  $self->{error} = "Conversion from OpenDocument to PDF failed. " .
737 737
    "Exit code: $res";
738 738

  
739 739
  $main::lxdebug->leave_sub();
......
754 754
sub get_mime_type() {
755 755
  my ($self) = @_;
756 756

  
757
  if ($self->{"form"}->{"format"} =~ /pdf/) {
757
  if ($self->{form}->{format} =~ /pdf/) {
758 758
    return "application/pdf";
759 759
  } else {
760 760
    return "application/vnd.oasis.opendocument.text";

Auch abrufbar als: Unified diff