Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 6d9d1fbf

Von Moritz Bunkus vor fast 8 Jahren hinzugefügt

  • ID 6d9d1fbf6d9478ab95144ce5d95300bd2ae46be8
  • Vorgänger 8a8629cf
  • Nachfolger 78efbe93

ActionBar: Verwendung bei Briefen

Unterschiede anzeigen:

SL/Controller/Letter.pm
171 171
sub action_list {
172 172
  my ($self, %params) = @_;
173 173

  
174
  $self->setup_list_action_bar;
174 175
  $self->make_filter_summary;
175 176
  $self->prepare_report;
176 177

  
177 178
  my $letters = $self->models->get;
178
  $self->report_generator_list_objects(report => $self->{report}, objects => $letters);
179
  $self->report_generator_list_objects(report => $self->{report}, objects => $letters, action_bar => 1);
179 180

  
180 181
}
181 182

  
......
323 324
    email      => $letter->contact ? $letter->contact->cp_email : '',
324 325
    subject    => $::form->generate_email_subject,
325 326
    a_filename => $::form->generate_attachment_filename,
326
    action     => 'Letter/send_email',
327 327
    HIDDEN     => \@hiddens,
328 328
    SHOW_BCC   => $::auth->assert('email_bcc', 'may fail'),
329 329
  );
330 330

  
331
  $self->render('generic/edit_email', %vars);
331
  $::request->layout->use_javascript("kivi.SalesPurchase.js");
332
  $self->setup_edit_email_action_bar;
333
  $self->render('letter/edit_email', %vars);
332 334
}
333 335

  
334 336
sub action_send_email {
......
348 350
sub _display {
349 351
  my ($self, %params) = @_;
350 352

  
351
  $::request->{layout}->use_javascript("${_}.js") for qw(ckeditor/ckeditor ckeditor/adapters/jquery);
353
  $::request->{layout}->use_javascript("${_}.js") for qw(ckeditor/ckeditor ckeditor/adapters/jquery kivi.Letter);
352 354

  
353 355
  my $letter = $self->letter;
354 356

  
......
364 366
  $::form->{languages}   ||= SL::DB::Manager::Language->get_all_sorted;
365 367
  $::form->{printers}      = SL::DB::Manager::Printer->get_all_sorted;
366 368

  
369
  $self->setup_display_action_bar;
367 370
  $self->render('letter/edit',
368 371
    %params,
369 372
    TCF           => [ map { key => $_, value => t8(ucfirst $_) }, TEXT_CREATED_FOR_VALUES() ],
......
416 419
    std_column_visibility => 1,
417 420
    controller_class      => 'Letter',
418 421
    output_format         => 'HTML',
419
    top_info_text         => t8('Letters'),
420 422
    title                 => t8('Letters'),
421 423
    allow_pdf_export      => 1,
422 424
    allow_csv_export      => 1,
......
485 487

  
486 488
  return unless @$letter_drafts;
487 489

  
490
  $self->setup_load_letter_draft_action_bar;
488 491
  $self->render('letter/load_drafts',
489 492
    title         => t8('Letter Draft'),
490 493
    LETTER_DRAFTS => $letter_drafts,
......
634 637
  $::auth->assert('sales_letter_report');
635 638
}
636 639

  
640
sub setup_load_letter_draft_action_bar {
641
  my ($self, %params) = @_;
642

  
643
  for my $bar ($::request->layout->get('actionbar')) {
644
    $bar->add(
645
      link => [
646
        t8('Skip'),
647
        link      => $self->url_for(action => 'skip_draft', is_sales => $self->is_sales),
648
        accesskey => 'enter',
649
      ],
650
      action => [
651
        t8('Delete'),
652
        submit  => [ '#form', { action => 'delete_drafts' } ],
653
        checks  => [ [ 'kivi.check_if_entries_selected', '[name="ids[+]"]' ] ],
654
        confirm => t8('Do you really want to delete this draft?'),
655
      ],
656
    );
657
  }
658
}
659

  
660
sub setup_display_action_bar {
661
  my ($self, %params) = @_;
662

  
663
  for my $bar ($::request->layout->get('actionbar')) {
664
    $bar->add(
665
      action => [
666
        t8('Update'),
667
        submit    => [ '#form', { action => 'Letter/update' } ],
668
        accesskey => 'enter',
669
      ],
670

  
671
      combobox => [
672
        action => [
673
          t8('Save'),
674
          submit => [ '#form', { action => 'Letter/save' } ],
675
        ],
676
        action => [
677
          t8('Save Draft'),
678
          submit => [ '#form', { action => 'Letter/save_letter_draft' } ],
679
        ],
680
      ], # end of combobox "Save"
681

  
682
      action => [
683
        t8('Delete'),
684
        submit   => [ '#form', { action => 'Letter/delete' } ],
685
        confirm  => t8('Are you sure you want to delete this letter?'),
686
        disabled => !$self->letter->id ? t8('The object has not been saved yet.') : undef,
687
      ],
688

  
689
      combobox => [
690
        action => [ t8('Export') ],
691
        action => [
692
          t8('Print'),
693
          submit   => [ '#form', { action => 'Letter/print_letter' } ],
694
          disabled => !$self->letter->id ? t8('The object has not been saved yet.') : undef,
695
        ],
696
        action => [
697
          t8('E-mail'),
698
          submit   => [ '#form', { action => 'Letter/edit_email' } ],
699
          disabled => !$self->letter->id ? t8('The object has not been saved yet.') : undef,
700
        ],
701
      ],
702
    );
703
  }
704
}
705

  
706
sub setup_edit_email_action_bar {
707
  my ($self, %params) = @_;
708

  
709
  for my $bar ($::request->layout->get('actionbar')) {
710
    $bar->add(
711
      action => [
712
        t8('Continue'),
713
        submit    => [ '#form', { action => 'Letter/send_email' } ],
714
        checks    => [ 'kivi.SalesPurchase.check_required_email_fields' ],
715
        accesskey => 'enter',
716
      ],
717
    );
718
  }
719
}
720

  
721
sub setup_list_action_bar {
722
  my ($self, %params) = @_;
723

  
724
  for my $bar ($::request->layout->get('actionbar')) {
725
    $bar->add(
726
      action => [
727
        t8('Search'),
728
        submit    => [ '#form', { action => 'Letter/list' } ],
729
        checks    => [ 'kivi.SalesPurchase.check_required_email_fields' ],
730
        accesskey => 'enter',
731
      ],
732
      action => [
733
        t8('Reset'),
734
        call => [ 'kivi.call_jquery', '#form', 'resetForm' ],
735
      ],
736
    );
737
  }
738
}
739

  
637 740
1;
638 741

  
639 742
__END__
js/kivi.Letter.js
1
namespace('kivi.Letter', function(ns) {
2
  "use strict";
3

  
4
  $(function() {
5
    $('#letter_customer_id,#letter_vendor_id').change(function(){
6
      var data = $('form').serializeArray();
7
      data.push({ name: 'action', value: 'Letter/update_contacts' });
8
      $.post('controller.pl', data, kivi.eval_json_result);
9
    });
10
  });
11
});
js/kivi.SalesPurchase.js
224 224
  };
225 225

  
226 226
  // Sending records via email.
227
  this.send_email = function() {
227
  this.check_required_email_fields = function() {
228 228
    var unset = $('#email_form_to,#email_form_subject,#email_form_message').filter(function(idx, elt) {
229 229
      return $(elt).val() === '';
230 230
    });
231 231

  
232
    if (unset.length > 0) {
233
      alert(kivi.t8("The recipient, subject or body is missing."));
234
      $(unset[0]).focus();
232
    if (unset.length === 0)
233
      return true;
234

  
235
    alert(kivi.t8("The recipient, subject or body is missing."));
236
    $(unset[0]).focus();
237

  
238
    return false;
239
  };
235 240

  
241
  this.send_email = function() {
242
    if (!kivi.SalesPurchase.check_required_email_fields())
236 243
      return false;
237
    }
238 244

  
239 245
    $('#send_email_dialog').children().remove().appendTo('#email_inputs');
240 246
    $('#send_email_dialog').dialog('close');
locale/de/all
771 771
  'Customer'                    => 'Kunde',
772 772
  'Customer (database ID)'      => 'Kunde (Datenbank-ID)',
773 773
  'Customer (name)'             => 'Kunde (Name)',
774
  'Customer Attachments'        => 'Anhänge des Kunden',
775 774
  'Customer Discount'           => 'Kundenrabatt',
776 775
  'Customer Master Data'        => 'Kundenstammdaten',
777 776
  'Customer Name'               => 'Kundenname',
......
901 900
  'Delete Images'               => 'Bilder löschen',
902 901
  'Delete Shipto'               => 'Lieferadresse löschen',
903 902
  'Delete all'                  => 'Alle Löschen',
904
  'Delete drafts'               => 'Entwürfe löschen',
905 903
  'Delete links'                => 'Verknüpfungen löschen',
906 904
  'Delete picture'              => 'Bild löschen',
907 905
  'Delete printfiles'           => 'Dokumente löschen',
......
1728 1726
  'Make (vendor\'s database ID, number or name; with X being a number)' => 'Lieferant (Datenbank-ID, Nummer oder Name des Lieferanten; X ist eine fortlaufende Zahl)',
1729 1727
  'Make compatible for import'  => 'Für den Import kompatibel machen',
1730 1728
  'Make default profile'        => 'Zu Standardprofil machen',
1731
  'Make new document'           => 'Erzeuge ein neue Datei',
1732 1729
  'Makemodel Price'             => 'Lieferantenpreis',
1733 1730
  'Manage Custom Variables'     => 'Benutzerdefinierte Variablen',
1734 1731
  'Mandantennummer'             => 'Mandantennummer',
......
1858 1855
  'No delievery orders selected, please set one checkbox!' => 'Kein Lieferschein selektiert, bitte eine Box anklicken!',
1859 1856
  'No delivery orders have been selected.' => 'Es wurden keine Lieferscheine ausgewählt.',
1860 1857
  'No delivery term has been created yet.' => 'Es wurden noch keine Lieferbedingungen angelegt',
1861
  'No document'                 => 'Kein Datei mitschicken (ggf. Anhänge)',
1862 1858
  'No dunnings have been selected for printing.' => 'Es wurden keine Mahnungen zum Drucken ausgewählt.',
1863 1859
  'No end date given, setting to today' => 'Kein Enddatum gegeben, setze Enddatum auf heute',
1864 1860
  'No entries have been imported yet.' => 'Es wurden noch keine Einträge importiert.',
......
2052 2048
  'Part "#1" has chargenumber or best before date set. So it cannot be transfered automatically.' => 'Bei Artikel "#1" ist eine Chargenummer oder ein Mindesthaltbarkeitsdatum vergeben. Deshalb kann dieser Artikel nicht automatisch ausgelagert werden.',
2053 2049
  'Part (database ID)'          => 'Artikel (Datenbank-ID)',
2054 2050
  'Part (typeabbreviation)'     => 'W',
2055
  'Part Attachments'            => 'Anhänge der Artikel',
2056 2051
  'Part Classification'         => 'Artikel-Klassifizierung',
2057 2052
  'Part Description'            => 'Artikelbeschreibung',
2058 2053
  'Part Description missing!'   => 'Artikelbezeichnung fehlt!',
......
3761 3756
  'only OB Transactions'        => 'nur EB-Buchungen',
3762 3757
  'open'                        => 'Offen',
3763 3758
  'order'                       => 'Reihenfolge',
3764
  'other Document Attachments'  => 'Weitere Dateianhänge',
3765 3759
  'our vendor number at customer' => 'Unsere Lieferanten-Nr. beim Kunden',
3766 3760
  'parsing csv'                 => 'Parse CSV Daten',
3767 3761
  'part'                        => 'Ware',
......
3851 3845
  'unnamed record template'     => 'unbenannte Belegvorlage',
3852 3846
  'until'                       => 'bis',
3853 3847
  'uploaded'                    => 'Hochgeladen',
3854
  'use actual document'         => 'Verwende aktuelle Datei',
3855 3848
  'use program settings'        => 'benutze Programmeinstellungen',
3856 3849
  'use user config'             => 'Verwende Benutzereinstellung',
3857 3850
  'used'                        => 'Verbraucht',
templates/webpages/generic/edit_email.html
1
[%- USE T8 %]
2
[%- USE HTML %][%- USE LxERP -%][%- USE L -%]
3
<h1>[% title %]</h1>
4

  
5
<form name="Form" method="post" action="[% script %]">
6

  
7
<table width="100%">
8
  <tr>
9
    <td style="width: 500px">
10
      <table>
11
        <tr>
12
          <th align="right" nowrap>[% 'To' | $T8 %]</th>
13

  
14
          <td>[% L.input_tag('email', email, size=30, class=(email ? '' : 'initial_focus')) %]</td>
15
        </tr>
16
        <tr>
17
          <th align="right" nowrap>[% 'Cc' | $T8 %]</th>
18
          <td><input name="cc" size="30" value="[% HTML.escape(cc) %]"></td>
19
        </tr>
20
[%- IF SHOW_BCC %]
21
        <tr>
22
          <th align="right" nowrap>[% 'Bcc' | $T8 %]</th>
23
          <td><input name="bcc" size="30" value="[% HTML.escape(bcc) %]"></td>
24
        </tr>
25
[%- END %]
26
        <tr>
27
          <th align="right" nowrap>[% 'Subject' | $T8 %]</th>
28
          <td>[% L.input_tag('subject', subject, size=30, class=(email ? 'initial_focus' : '')) %]</td>
29
        </tr>
30
        <tr>
31
          <th align="right" nowrap>[% 'Attachment name' | $T8 %]</th>
32
          <td><input name="attachment_filename" size="30" value="[% HTML.escape(a_filename) %]"></td>
33
        </tr>
34
      </table>
35
    </td>
36
[%- IF INSTANCE_CONF.get_doc_storage %]
37
    <td align="left" rowspan="2">
38
      <table>
39
[%- USE ATT_it = Iterator(FILES) %]
40
[% FOREACH file = ATT_it %]
41
[% END %]
42
[%- IF ATT_it.size > 0 %]  
43
        <tr class="listheading">
44
          <th colspan="3" align="left" nowrap>[% LxERP.t8('other Document Attachments') %]</th>
45
          <input type="hidden" name="attfile_count" id="m_attfile_count" value="[% ATT_it.size %]">
46
        </tr>
47
         <tr class="">
48
           <th align="left" nowrap></th>
49
           <th align="left" nowrap>[% LxERP.t8('Filename') %]</th>
50
           <th align="left" nowrap></th>
51
        </tr>
52
        <tr><td colspan="3"><hr size="1" style="height:1px;background-color:#000;" noshade></td></tr>
53
       [% FOREACH file = ATT_it %]
54
         <tr class="listrow">
55
          <td></td><td>[% file.file_name %]
56
            <input type="hidden" name="attfile_[% ATT_it.count %]" value="[% file.id %]">
57
            <td><input name="attsel_[% ATT_it.count %]" type="checkbox" class="checkbox" ></td>
58
         </tr>
59
        [% END %]
60
[%- END %]
61
[%- USE ATT_it = Iterator(VC_FILES) %]
62
[% FOREACH file = ATT_it %]
63
[% END %]
64
[%- IF ATT_it.size > 0 %]  
65
        <tr><td colspan="3"><hr size="1" noshade></td></tr>
66
         <tr class="listheading">
67
           <th colspan="3" align="left" nowrap>
68
             <input type="hidden" name="attfile_cv_count" id="m_attfile_cv_count" value="[% ATT_it.size %]">
69
             [% LxERP.t8('Customer Attachments') %]
70
           </th>
71
         </tr>
72
        <tr class="">
73
           <th align="left" nowrap></th>
74
           <th align="left" nowrap>[% LxERP.t8('Filename') %]</th>
75
           <th align="left" nowrap></th>
76
        </tr>
77
        <tr><td colspan="3"><hr size="1" style="height:1px;background-color:#000;" noshade></td></tr>
78
        [% FOREACH file = ATT_it %]
79
         <tr class="listrow">
80
          <td></td><td>[% file.file_name %]
81
            <input type="hidden" name="attfile_cv_[% ATT_it.count %]" value="[% file.id %]">
82
            <td><input name="attsel_cv_[% ATT_it.count %]" type="checkbox" class="checkbox" ></td>
83
         </tr>
84
        [% END %]
85
[%- END %]
86
[%- USE ATT_it = Iterator(PART_FILES) %]
87
[%- SET lastpartid = '' %]  
88
[%- FOREACH file = ATT_it %]
89
[%- END %]
90
[%- IF ATT_it.size > 0 %]  
91
        <tr><td colspan="3"><hr size="1" noshade></td></tr>
92
         <tr class="listheading">
93
          <th colspan="3" align="left" nowrap>
94
            <input type="hidden" name="attfile_part_count" id="m_attfile_part_count" value="[% ATT_it.size %]">
95
            [% LxERP.t8('Part Attachments') %]
96
          </th>
97
        </tr>
98
        <tr class="">
99
           <th align="left" nowrap>[% LxERP.t8('Part Number') %]</th>
100
           <th align="left" nowrap>[% LxERP.t8('Filename') %]</th>
101
           <th align="left" nowrap></th>
102
        </tr>
103
        [% FOREACH file = ATT_it %]
104
          [%- IF lastpartid != file.trans_id %]
105
             [%- SET lastpartid = file.trans_id %][%- SET partname = file.partname %]
106
        <tr><td colspan="3"><hr size="1" style="height:1px;background-color:#000;" noshade></td></tr>
107
          [%- ELSE %][%- SET partname = '' %][% END %]          
108
        <tr class="listrow">
109
          <td>[% partname %]</td>
110
          <td>[% file.file_name %]
111
            <input type="hidden" name="attfile_part_[% ATT_it.count %]" value="[% file.id %]">
112
            <td><input name="attsel_part_[% ATT_it.count %]" type="checkbox" class="checkbox" ></td>
113
         </tr>
114
        [% END %]
115
[%- END %]
116
      </table>
117
    </td>
118
[%- ELSE %]
119
    <td rowspan="2">
120
    </td>
121
[%- END %]
122
  </tr>
123

  
124
  <tr>
125
    <td>
126
      <table>
127
        <tr>
128
          <th align="left" nowrap>[% 'Message' | $T8 %]</th>
129
        </tr>
130
        <tr>
131
          <td><textarea name="message" id="message" rows="15" cols="60" wrap="soft">[% HTML.escape(message) %]</textarea></td>
132

  
133
        </tr>
134
      </table>
135
    </td>
136
  </tr>
137
  <tr>
138
    <td colspan="2">
139

  
140
[% print_options %]
141
[% FOREACH row = HIDDEN %]<input type="hidden" name="[% row.name %]" value="[% HTML.escape(row.value) %]">
142
[% END %]
143

  
144
    </td>
145
  </tr>
146

  
147
  <tr>
148
    <td colspan="2"><hr size="3" noshade></td>
149
  </tr>
150
</table>
151

  
152
[% L.hidden_tag('action', action) %]
153

  
154
<br>
155
[% L.submit_tag('action_newfile', LxERP.t8('Make new document'), onclick="return check_prerequisites();") %]
156
[%- IF has_document %]  
157
[% L.submit_tag('action_oldfile', LxERP.t8('use actual document'), onclick="return check_prerequisites();") %]
158
[%- END %]
159
[% L.submit_tag('action_nofile',  LxERP.t8('No document'), onclick="return check_prerequisites();") %]
160
</form>
161

  
162
<script type="text/javascript">
163
<!--
164
function check_prerequisites() {
165
  if (!$('#email,#subject,#message').filter(function(idx, elt) { return $(elt).val() === ""; }).size())
166
    return true;
167

  
168
  alert(kivi.t8('The recipient, subject or body is missing.'));
169
  return false;
170
}
171
-->
172
</script>
templates/webpages/letter/edit.html
6 6
[%- SET WEBDAV = SELF.webdav_objects %]
7 7
<h1>[% title | html %]</h1>
8 8

  
9
<form action='controller.pl' method='POST'>
9
<form action='controller.pl' method='POST' id='form'>
10 10
  <input type="hidden" name="letter.id" value="[% letter.id | html %]">
11 11
  <input type="hidden" name="draft.id" value="[% draft.id | html %]">
12 12
  <input type="hidden" name="type" value="[% type | html %]">
......
149 149
  [%- LxERP.t8("Loading...") %]
150 150
 </div>
151 151
</div>
152

  
153
<input type="hidden" name="action" value="Letter/dispatch">
154
<input class="submit" type="submit" name="action_update" id="update_button" value="[% 'Update' | $T8 %]">
155

  
156
[%- IF letter.letternumber %]
157
  <input class="submit" type="submit" name="action_edit_email" value="[% 'E-mail' | $T8 %]">
158
  <input class="submit" type="submit" name="action_print_letter" value="[% 'Print' | $T8 %]">
159
[% END %]
160

  
161
<input class="submit" type="submit" name="action_save" value="[% 'Save' | $T8 %]">
162
[% L.submit_tag('action_delete', LxERP.t8('Delete'), confirm=LxERP.t8('Are you sure you want to delete this letter?')) %]
163
<input class="submit" type="submit" name="action_save_letter_draft" value="[% 'Save Draft' | $T8 %]">
164

  
165 152
</form>
166

  
167

  
168
<script type='text/javascript'>
169
  $(function(){
170
    $('#letter_customer_id').change(function(){
171
      var data = $('form').serializeArray();
172
      data.push({ name: 'action_update_contacts', value: 1 });
173
      $.post('controller.pl', data, kivi.eval_json_result);
174
    });
175
    $('#letter_vendor_id').change(function(){
176
      var data = $('form').serializeArray();
177
      data.push({ name: 'action_update_contacts', value: 1 });
178
      $.post('controller.pl', data, kivi.eval_json_result);
179
    })
180
  })
181
</script>
templates/webpages/letter/load_drafts.html
2 2
[%- USE HTML %][%- USE L -%]
3 3
<h1>[% 'Load letter draft' | $T8 %]</h1>
4 4

  
5
 <form method="post" name="Form" action="controller.pl">
5
 <form method="post" name="Form" action="controller.pl" id="form">
6
  [% L.hidden_tag('is_sales', SELF.is_sales) %]
6 7
  <p>[% 'The following drafts have been saved and can be loaded.' | $T8 %]</p>
7 8
  <table width="100%">
8 9
    </td>
......
36 37
     </table>
37 38
    </td>
38 39
   </tr>
39
   <tr>
40
    <td>
41
     <input type="hidden" name="action" value="Letter/dispatch">
42
     [% L.hidden_tag('is_sales', SELF.is_sales) %]
43
     <input type="submit" class="submit" name="action_skip_draft" value="[% 'Skip' | $T8 %]">
44
     <input type="submit" class="submit" name="action_delete_drafts" value="[% 'Delete drafts' | $T8 %]">
45
   </td>
46
   </tr>
47 40
  </table>
48 41
 </form>
templates/webpages/letter/report_top.html
1 1
[%- PROCESS 'letter/search.html' filter=SELF.models.filtered.laundered %]
2 2
<hr>
3

  
4

  
templates/webpages/letter/search.html
2 2
[% USE T8 %]
3 3
[% USE L %]
4 4
[% USE LxERP %]
5
<form action="controller.pl" method="post" name="Form">
5
<form action="controller.pl" method="post" name="Form" id="form">
6 6

  
7 7
<div class='filter_toggle'>
8 8
<a href='#' onClick='javascript:$(".filter_toggle").toggle()'>[% 'Show Filter' | $T8 %]</a>
......
55 55
 [% L.hidden_tag('sort_by', FORM.sort_by) %]
56 56
 [% L.hidden_tag('sort_dir', FORM.sort_dir) %]
57 57
 [% L.hidden_tag('page', FORM.page) %]
58
 [% L.hidden_tag('action', 'Letter/dispatch') %]
59
 [% L.submit_tag('action_list', LxERP.t8('Continue')) %]
60

  
61
<a href='#' onClick='javascript:$("#filter_table input").val("");$("#filter_table input[type=checkbox]").prop("checked", 0);$("#filter_table select").prop("selectedIndex", 0);'>[% 'Reset' | $T8 %]</a>
62 58
</div>
63 59

  
64 60
</form>

Auch abrufbar als: Unified diff