sub action_list {
my ($self, %params) = @_;
+ $self->setup_list_action_bar;
$self->make_filter_summary;
$self->prepare_report;
my $letters = $self->models->get;
- $self->report_generator_list_objects(report => $self->{report}, objects => $letters);
+ $self->report_generator_list_objects(report => $self->{report}, objects => $letters, action_bar => 1);
}
email => $letter->contact ? $letter->contact->cp_email : '',
subject => $::form->generate_email_subject,
a_filename => $::form->generate_attachment_filename,
- action => 'Letter/send_email',
HIDDEN => \@hiddens,
SHOW_BCC => $::auth->assert('email_bcc', 'may fail'),
);
- $self->render('generic/edit_email', %vars);
+ $::request->layout->use_javascript("kivi.SalesPurchase.js");
+ $self->setup_edit_email_action_bar;
+ $self->render('letter/edit_email', %vars);
}
sub action_send_email {
sub _display {
my ($self, %params) = @_;
- $::request->{layout}->use_javascript("${_}.js") for qw(ckeditor/ckeditor ckeditor/adapters/jquery);
+ $::request->{layout}->use_javascript("${_}.js") for qw(ckeditor/ckeditor ckeditor/adapters/jquery kivi.Letter);
my $letter = $self->letter;
$::form->{languages} ||= SL::DB::Manager::Language->get_all_sorted;
$::form->{printers} = SL::DB::Manager::Printer->get_all_sorted;
+ $self->setup_display_action_bar;
$self->render('letter/edit',
%params,
TCF => [ map { key => $_, value => t8(ucfirst $_) }, TEXT_CREATED_FOR_VALUES() ],
std_column_visibility => 1,
controller_class => 'Letter',
output_format => 'HTML',
- top_info_text => t8('Letters'),
title => t8('Letters'),
allow_pdf_export => 1,
allow_csv_export => 1,
return unless @$letter_drafts;
+ $self->setup_load_letter_draft_action_bar;
$self->render('letter/load_drafts',
title => t8('Letter Draft'),
LETTER_DRAFTS => $letter_drafts,
$::auth->assert('sales_letter_report');
}
+sub setup_load_letter_draft_action_bar {
+ my ($self, %params) = @_;
+
+ for my $bar ($::request->layout->get('actionbar')) {
+ $bar->add(
+ link => [
+ t8('Skip'),
+ link => $self->url_for(action => 'skip_draft', is_sales => $self->is_sales),
+ accesskey => 'enter',
+ ],
+ action => [
+ t8('Delete'),
+ submit => [ '#form', { action => 'delete_drafts' } ],
+ checks => [ [ 'kivi.check_if_entries_selected', '[name="ids[+]"]' ] ],
+ confirm => t8('Do you really want to delete this draft?'),
+ ],
+ );
+ }
+}
+
+sub setup_display_action_bar {
+ my ($self, %params) = @_;
+
+ for my $bar ($::request->layout->get('actionbar')) {
+ $bar->add(
+ action => [
+ t8('Update'),
+ submit => [ '#form', { action => 'Letter/update' } ],
+ accesskey => 'enter',
+ ],
+
+ combobox => [
+ action => [
+ t8('Save'),
+ submit => [ '#form', { action => 'Letter/save' } ],
+ ],
+ action => [
+ t8('Save Draft'),
+ submit => [ '#form', { action => 'Letter/save_letter_draft' } ],
+ ],
+ ], # end of combobox "Save"
+
+ action => [
+ t8('Delete'),
+ submit => [ '#form', { action => 'Letter/delete' } ],
+ confirm => t8('Are you sure you want to delete this letter?'),
+ disabled => !$self->letter->id ? t8('The object has not been saved yet.') : undef,
+ ],
+
+ combobox => [
+ action => [ t8('Export') ],
+ action => [
+ t8('Print'),
+ submit => [ '#form', { action => 'Letter/print_letter' } ],
+ disabled => !$self->letter->id ? t8('The object has not been saved yet.') : undef,
+ ],
+ action => [
+ t8('E-mail'),
+ submit => [ '#form', { action => 'Letter/edit_email' } ],
+ disabled => !$self->letter->id ? t8('The object has not been saved yet.') : undef,
+ ],
+ ],
+ );
+ }
+}
+
+sub setup_edit_email_action_bar {
+ my ($self, %params) = @_;
+
+ for my $bar ($::request->layout->get('actionbar')) {
+ $bar->add(
+ action => [
+ t8('Continue'),
+ submit => [ '#form', { action => 'Letter/send_email' } ],
+ checks => [ 'kivi.SalesPurchase.check_required_email_fields' ],
+ accesskey => 'enter',
+ ],
+ );
+ }
+}
+
+sub setup_list_action_bar {
+ my ($self, %params) = @_;
+
+ for my $bar ($::request->layout->get('actionbar')) {
+ $bar->add(
+ action => [
+ t8('Search'),
+ submit => [ '#form', { action => 'Letter/list' } ],
+ checks => [ 'kivi.SalesPurchase.check_required_email_fields' ],
+ accesskey => 'enter',
+ ],
+ action => [
+ t8('Reset'),
+ call => [ 'kivi.call_jquery', '#form', 'resetForm' ],
+ ],
+ );
+ }
+}
+
1;
__END__
--- /dev/null
+namespace('kivi.Letter', function(ns) {
+ "use strict";
+
+ $(function() {
+ $('#letter_customer_id,#letter_vendor_id').change(function(){
+ var data = $('form').serializeArray();
+ data.push({ name: 'action', value: 'Letter/update_contacts' });
+ $.post('controller.pl', data, kivi.eval_json_result);
+ });
+ });
+});
};
// Sending records via email.
- this.send_email = function() {
+ this.check_required_email_fields = function() {
var unset = $('#email_form_to,#email_form_subject,#email_form_message').filter(function(idx, elt) {
return $(elt).val() === '';
});
- if (unset.length > 0) {
- alert(kivi.t8("The recipient, subject or body is missing."));
- $(unset[0]).focus();
+ if (unset.length === 0)
+ return true;
+
+ alert(kivi.t8("The recipient, subject or body is missing."));
+ $(unset[0]).focus();
+
+ return false;
+ };
+ this.send_email = function() {
+ if (!kivi.SalesPurchase.check_required_email_fields())
return false;
- }
$('#send_email_dialog').children().remove().appendTo('#email_inputs');
$('#send_email_dialog').dialog('close');
'Customer' => 'Kunde',
'Customer (database ID)' => 'Kunde (Datenbank-ID)',
'Customer (name)' => 'Kunde (Name)',
- 'Customer Attachments' => 'Anhänge des Kunden',
'Customer Discount' => 'Kundenrabatt',
'Customer Master Data' => 'Kundenstammdaten',
'Customer Name' => 'Kundenname',
'Delete Images' => 'Bilder löschen',
'Delete Shipto' => 'Lieferadresse löschen',
'Delete all' => 'Alle Löschen',
- 'Delete drafts' => 'Entwürfe löschen',
'Delete links' => 'Verknüpfungen löschen',
'Delete picture' => 'Bild löschen',
'Delete printfiles' => 'Dokumente löschen',
'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)',
'Make compatible for import' => 'Für den Import kompatibel machen',
'Make default profile' => 'Zu Standardprofil machen',
- 'Make new document' => 'Erzeuge ein neue Datei',
'Makemodel Price' => 'Lieferantenpreis',
'Manage Custom Variables' => 'Benutzerdefinierte Variablen',
'Mandantennummer' => 'Mandantennummer',
'No delievery orders selected, please set one checkbox!' => 'Kein Lieferschein selektiert, bitte eine Box anklicken!',
'No delivery orders have been selected.' => 'Es wurden keine Lieferscheine ausgewählt.',
'No delivery term has been created yet.' => 'Es wurden noch keine Lieferbedingungen angelegt',
- 'No document' => 'Kein Datei mitschicken (ggf. Anhänge)',
'No dunnings have been selected for printing.' => 'Es wurden keine Mahnungen zum Drucken ausgewählt.',
'No end date given, setting to today' => 'Kein Enddatum gegeben, setze Enddatum auf heute',
'No entries have been imported yet.' => 'Es wurden noch keine Einträge importiert.',
'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.',
'Part (database ID)' => 'Artikel (Datenbank-ID)',
'Part (typeabbreviation)' => 'W',
- 'Part Attachments' => 'Anhänge der Artikel',
'Part Classification' => 'Artikel-Klassifizierung',
'Part Description' => 'Artikelbeschreibung',
'Part Description missing!' => 'Artikelbezeichnung fehlt!',
'only OB Transactions' => 'nur EB-Buchungen',
'open' => 'Offen',
'order' => 'Reihenfolge',
- 'other Document Attachments' => 'Weitere Dateianhänge',
'our vendor number at customer' => 'Unsere Lieferanten-Nr. beim Kunden',
'parsing csv' => 'Parse CSV Daten',
'part' => 'Ware',
'unnamed record template' => 'unbenannte Belegvorlage',
'until' => 'bis',
'uploaded' => 'Hochgeladen',
- 'use actual document' => 'Verwende aktuelle Datei',
'use program settings' => 'benutze Programmeinstellungen',
'use user config' => 'Verwende Benutzereinstellung',
'used' => 'Verbraucht',
+++ /dev/null
-[%- USE T8 %]
-[%- USE HTML %][%- USE LxERP -%][%- USE L -%]
-<h1>[% title %]</h1>
-
-<form name="Form" method="post" action="[% script %]">
-
-<table width="100%">
- <tr>
- <td style="width: 500px">
- <table>
- <tr>
- <th align="right" nowrap>[% 'To' | $T8 %]</th>
-
- <td>[% L.input_tag('email', email, size=30, class=(email ? '' : 'initial_focus')) %]</td>
- </tr>
- <tr>
- <th align="right" nowrap>[% 'Cc' | $T8 %]</th>
- <td><input name="cc" size="30" value="[% HTML.escape(cc) %]"></td>
- </tr>
-[%- IF SHOW_BCC %]
- <tr>
- <th align="right" nowrap>[% 'Bcc' | $T8 %]</th>
- <td><input name="bcc" size="30" value="[% HTML.escape(bcc) %]"></td>
- </tr>
-[%- END %]
- <tr>
- <th align="right" nowrap>[% 'Subject' | $T8 %]</th>
- <td>[% L.input_tag('subject', subject, size=30, class=(email ? 'initial_focus' : '')) %]</td>
- </tr>
- <tr>
- <th align="right" nowrap>[% 'Attachment name' | $T8 %]</th>
- <td><input name="attachment_filename" size="30" value="[% HTML.escape(a_filename) %]"></td>
- </tr>
- </table>
- </td>
-[%- IF INSTANCE_CONF.get_doc_storage %]
- <td align="left" rowspan="2">
- <table>
-[%- USE ATT_it = Iterator(FILES) %]
-[% FOREACH file = ATT_it %]
-[% END %]
-[%- IF ATT_it.size > 0 %]
- <tr class="listheading">
- <th colspan="3" align="left" nowrap>[% LxERP.t8('other Document Attachments') %]</th>
- <input type="hidden" name="attfile_count" id="m_attfile_count" value="[% ATT_it.size %]">
- </tr>
- <tr class="">
- <th align="left" nowrap></th>
- <th align="left" nowrap>[% LxERP.t8('Filename') %]</th>
- <th align="left" nowrap></th>
- </tr>
- <tr><td colspan="3"><hr size="1" style="height:1px;background-color:#000;" noshade></td></tr>
- [% FOREACH file = ATT_it %]
- <tr class="listrow">
- <td></td><td>[% file.file_name %]
- <input type="hidden" name="attfile_[% ATT_it.count %]" value="[% file.id %]">
- <td><input name="attsel_[% ATT_it.count %]" type="checkbox" class="checkbox" ></td>
- </tr>
- [% END %]
-[%- END %]
-[%- USE ATT_it = Iterator(VC_FILES) %]
-[% FOREACH file = ATT_it %]
-[% END %]
-[%- IF ATT_it.size > 0 %]
- <tr><td colspan="3"><hr size="1" noshade></td></tr>
- <tr class="listheading">
- <th colspan="3" align="left" nowrap>
- <input type="hidden" name="attfile_cv_count" id="m_attfile_cv_count" value="[% ATT_it.size %]">
- [% LxERP.t8('Customer Attachments') %]
- </th>
- </tr>
- <tr class="">
- <th align="left" nowrap></th>
- <th align="left" nowrap>[% LxERP.t8('Filename') %]</th>
- <th align="left" nowrap></th>
- </tr>
- <tr><td colspan="3"><hr size="1" style="height:1px;background-color:#000;" noshade></td></tr>
- [% FOREACH file = ATT_it %]
- <tr class="listrow">
- <td></td><td>[% file.file_name %]
- <input type="hidden" name="attfile_cv_[% ATT_it.count %]" value="[% file.id %]">
- <td><input name="attsel_cv_[% ATT_it.count %]" type="checkbox" class="checkbox" ></td>
- </tr>
- [% END %]
-[%- END %]
-[%- USE ATT_it = Iterator(PART_FILES) %]
-[%- SET lastpartid = '' %]
-[%- FOREACH file = ATT_it %]
-[%- END %]
-[%- IF ATT_it.size > 0 %]
- <tr><td colspan="3"><hr size="1" noshade></td></tr>
- <tr class="listheading">
- <th colspan="3" align="left" nowrap>
- <input type="hidden" name="attfile_part_count" id="m_attfile_part_count" value="[% ATT_it.size %]">
- [% LxERP.t8('Part Attachments') %]
- </th>
- </tr>
- <tr class="">
- <th align="left" nowrap>[% LxERP.t8('Part Number') %]</th>
- <th align="left" nowrap>[% LxERP.t8('Filename') %]</th>
- <th align="left" nowrap></th>
- </tr>
- [% FOREACH file = ATT_it %]
- [%- IF lastpartid != file.trans_id %]
- [%- SET lastpartid = file.trans_id %][%- SET partname = file.partname %]
- <tr><td colspan="3"><hr size="1" style="height:1px;background-color:#000;" noshade></td></tr>
- [%- ELSE %][%- SET partname = '' %][% END %]
- <tr class="listrow">
- <td>[% partname %]</td>
- <td>[% file.file_name %]
- <input type="hidden" name="attfile_part_[% ATT_it.count %]" value="[% file.id %]">
- <td><input name="attsel_part_[% ATT_it.count %]" type="checkbox" class="checkbox" ></td>
- </tr>
- [% END %]
-[%- END %]
- </table>
- </td>
-[%- ELSE %]
- <td rowspan="2">
- </td>
-[%- END %]
- </tr>
-
- <tr>
- <td>
- <table>
- <tr>
- <th align="left" nowrap>[% 'Message' | $T8 %]</th>
- </tr>
- <tr>
- <td><textarea name="message" id="message" rows="15" cols="60" wrap="soft">[% HTML.escape(message) %]</textarea></td>
-
- </tr>
- </table>
- </td>
- </tr>
- <tr>
- <td colspan="2">
-
-[% print_options %]
-[% FOREACH row = HIDDEN %]<input type="hidden" name="[% row.name %]" value="[% HTML.escape(row.value) %]">
-[% END %]
-
- </td>
- </tr>
-
- <tr>
- <td colspan="2"><hr size="3" noshade></td>
- </tr>
-</table>
-
-[% L.hidden_tag('action', action) %]
-
-<br>
-[% L.submit_tag('action_newfile', LxERP.t8('Make new document'), onclick="return check_prerequisites();") %]
-[%- IF has_document %]
-[% L.submit_tag('action_oldfile', LxERP.t8('use actual document'), onclick="return check_prerequisites();") %]
-[%- END %]
-[% L.submit_tag('action_nofile', LxERP.t8('No document'), onclick="return check_prerequisites();") %]
-</form>
-
-<script type="text/javascript">
-<!--
-function check_prerequisites() {
- if (!$('#email,#subject,#message').filter(function(idx, elt) { return $(elt).val() === ""; }).size())
- return true;
-
- alert(kivi.t8('The recipient, subject or body is missing.'));
- return false;
-}
--->
-</script>
[%- SET WEBDAV = SELF.webdav_objects %]
<h1>[% title | html %]</h1>
-<form action='controller.pl' method='POST'>
+<form action='controller.pl' method='POST' id='form'>
<input type="hidden" name="letter.id" value="[% letter.id | html %]">
<input type="hidden" name="draft.id" value="[% draft.id | html %]">
<input type="hidden" name="type" value="[% type | html %]">
[%- LxERP.t8("Loading...") %]
</div>
</div>
-
-<input type="hidden" name="action" value="Letter/dispatch">
-<input class="submit" type="submit" name="action_update" id="update_button" value="[% 'Update' | $T8 %]">
-
-[%- IF letter.letternumber %]
- <input class="submit" type="submit" name="action_edit_email" value="[% 'E-mail' | $T8 %]">
- <input class="submit" type="submit" name="action_print_letter" value="[% 'Print' | $T8 %]">
-[% END %]
-
-<input class="submit" type="submit" name="action_save" value="[% 'Save' | $T8 %]">
-[% L.submit_tag('action_delete', LxERP.t8('Delete'), confirm=LxERP.t8('Are you sure you want to delete this letter?')) %]
-<input class="submit" type="submit" name="action_save_letter_draft" value="[% 'Save Draft' | $T8 %]">
-
</form>
-
-
-<script type='text/javascript'>
- $(function(){
- $('#letter_customer_id').change(function(){
- var data = $('form').serializeArray();
- data.push({ name: 'action_update_contacts', value: 1 });
- $.post('controller.pl', data, kivi.eval_json_result);
- });
- $('#letter_vendor_id').change(function(){
- var data = $('form').serializeArray();
- data.push({ name: 'action_update_contacts', value: 1 });
- $.post('controller.pl', data, kivi.eval_json_result);
- })
- })
-</script>
[%- USE HTML %][%- USE L -%]
<h1>[% 'Load letter draft' | $T8 %]</h1>
- <form method="post" name="Form" action="controller.pl">
+ <form method="post" name="Form" action="controller.pl" id="form">
+ [% L.hidden_tag('is_sales', SELF.is_sales) %]
<p>[% 'The following drafts have been saved and can be loaded.' | $T8 %]</p>
<table width="100%">
</td>
</table>
</td>
</tr>
- <tr>
- <td>
- <input type="hidden" name="action" value="Letter/dispatch">
- [% L.hidden_tag('is_sales', SELF.is_sales) %]
- <input type="submit" class="submit" name="action_skip_draft" value="[% 'Skip' | $T8 %]">
- <input type="submit" class="submit" name="action_delete_drafts" value="[% 'Delete drafts' | $T8 %]">
- </td>
- </tr>
</table>
</form>
[%- PROCESS 'letter/search.html' filter=SELF.models.filtered.laundered %]
<hr>
-
-
[% USE T8 %]
[% USE L %]
[% USE LxERP %]
-<form action="controller.pl" method="post" name="Form">
+<form action="controller.pl" method="post" name="Form" id="form">
<div class='filter_toggle'>
<a href='#' onClick='javascript:$(".filter_toggle").toggle()'>[% 'Show Filter' | $T8 %]</a>
[% L.hidden_tag('sort_by', FORM.sort_by) %]
[% L.hidden_tag('sort_dir', FORM.sort_dir) %]
[% L.hidden_tag('page', FORM.page) %]
- [% L.hidden_tag('action', 'Letter/dispatch') %]
- [% L.submit_tag('action_list', LxERP.t8('Continue')) %]
-
-<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>
</div>
</form>