1 namespace('kivi.MassInvoiceCreatePrint', function(ns) {
2 this.checkSalesOrderSelection = function() {
3 if ($("[data-checkall=1]:checked").size() > 0)
5 alert(kivi.t8('No delivery orders have been selected.'));
9 this.checkDeliveryOrderSelection = function() {
10 if ($("[data-checkall=1]:checked").size() > 0)
12 alert(kivi.t8('No delivery orders have been selected.'));
15 this.checkInvoiceSelection = function() {
16 if ($("[data-checkall=1]:checked").size() > 0)
18 alert(kivi.t8('No invoices have been selected.'));
22 this.submitMassCreationForm = function() {
23 if (!kivi.MassInvoiceCreatePrint.checkDeliveryOrderSelection())
26 $('body').addClass('loading');
31 this.createPrintAllInitialize = function() {
33 id: 'create_print_all_dialog',
35 title: kivi.t8('Create and print all invoices')
40 this.createPrintAllStartProcess = function() {
41 $('#cpa_start_process_button,.ui-dialog-titlebar button.ui-dialog-titlebar-close').prop('disabled', 'disabled');
42 $('#cpa_start_process_abort_link').remove();
44 var filter = $('[name^=filter\\.]').serializeArray();
46 action: 'MassInvoiceCreatePrint/create_print_all_start',
47 number_of_invoices: $('#cpa_number_of_invoices').val(),
48 bothsided: $('#cpa_bothsided').val(),
49 printer_id: $('#cpa_printer_id').val(),
50 copy_printer_id: $('#cpa_copy_printer_id').val(),
51 transdate: $('#transdate').val()
54 $(filter).each(function(index, obj){ data[obj.name] = obj.value; });
56 $.post('controller.pl', data, kivi.eval_json_result);
59 this.createPrintAllFinishProcess = function() {
60 $('#create_print_all_dialog').dialog('close');
61 window.location.href = 'controller.pl?action=MassInvoiceCreatePrint%2flist_invoices&noshow=1';
64 this.massConversionStarted = function() {
65 $('#create_print_all_dialog').data('timerId', setInterval(function() {
66 $.get("controller.pl", {
67 action: 'MassInvoiceCreatePrint/create_print_all_status',
68 job_id: $('#cpa_job_id').val()
69 }, kivi.eval_json_result);
73 this.massConversionFinished = function() {
74 clearInterval($('#create_print_all_dialog').data('timerId'));
75 $('.ui-dialog-titlebar button.ui-dialog-titlebar-close').prop('disabled', '')
78 this.setup = function() {
79 $('#create_button').click(kivi.MassInvoiceCreatePrint.submitMassCreationForm);
80 $('#create_print_all_button').click(kivi.MassInvoiceCreatePrint.createPrintAllInitialize);
81 $('#action_print').click(kivi.MassInvoiceCreatePrint.checkInvoiceSelection);
85 $(kivi.MassInvoiceCreatePrint.setup);