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 printer_id: $('#cpa_printer_id').val(),
49 copy_printer_id: $('#cpa_copy_printer_id').val(),
50 transdate: $('#transdate').val()
53 $(filter).each(function(index, obj){ data[obj.name] = obj.value; });
55 $.post('controller.pl', data, kivi.eval_json_result);
58 this.createPrintAllFinishProcess = function() {
59 $('#create_print_all_dialog').dialog('close');
60 window.location.href = 'controller.pl?action=MassInvoiceCreatePrint%2flist_invoices&noshow=1';
63 this.massConversionStarted = function() {
64 $('#create_print_all_dialog').data('timerId', setInterval(function() {
65 $.get("controller.pl", {
66 action: 'MassInvoiceCreatePrint/create_print_all_status',
67 job_id: $('#cpa_job_id').val()
68 }, kivi.eval_json_result);
72 this.massConversionFinished = function() {
73 clearInterval($('#create_print_all_dialog').data('timerId'));
74 $('.ui-dialog-titlebar button.ui-dialog-titlebar-close').prop('disabled', '')
77 this.setup = function() {
78 $('#create_button').click(kivi.MassInvoiceCreatePrint.submitMassCreationForm);
79 $('#create_print_all_button').click(kivi.MassInvoiceCreatePrint.createPrintAllInitialize);
80 $('#action_print').click(kivi.MassInvoiceCreatePrint.checkInvoiceSelection);
84 $(kivi.MassInvoiceCreatePrint.setup);