mirror of
https://github.com/rickbarrette/redmine_qbo.git
synced 2026-02-13 01:03:59 -05:00
Select All Invoices For Bulk PDF
This commit is contained in:
@@ -26,10 +26,10 @@ class InvoiceController < ApplicationController
|
|||||||
service = Quickbooks::Service::Invoice.new(:company_id => qbo.realm_id, :access_token => access_token)
|
service = Quickbooks::Service::Invoice.new(:company_id => qbo.realm_id, :access_token => access_token)
|
||||||
|
|
||||||
# If multiple id's then pull each pdf & combine them
|
# If multiple id's then pull each pdf & combine them
|
||||||
if params[:item_ids]
|
if params[:invoice_ids]
|
||||||
logger.info("Grabbing pdfs for " + params[:item_ids].join(', '))
|
logger.info("Grabbing pdfs for " + params[:invoice_ids].join(', '))
|
||||||
ref = ""
|
ref = ""
|
||||||
params[:item_ids].each do |i|
|
params[:invoice_ids].each do |i|
|
||||||
logger.info("processing " + i)
|
logger.info("processing " + i)
|
||||||
invoice = service.fetch_by_id(i)
|
invoice = service.fetch_by_id(i)
|
||||||
ref += " #{invoice.doc_number}"
|
ref += " #{invoice.doc_number}"
|
||||||
|
|||||||
@@ -3,13 +3,15 @@
|
|||||||
<%= form_with(url: invoice_path, method: :get) do |form| %>
|
<%= form_with(url: invoice_path, method: :get) do |form| %>
|
||||||
|
|
||||||
<div class="form-check">
|
<div class="form-check">
|
||||||
<%= check_box_tag "select_all", "1", false, id: "select-all-batches" %>
|
<%= check_box_tag "select-all-invoices", "1", false, id: "select-all-invoices" %>
|
||||||
<%= label_tag "select-all-batches", "Select All Items" %>
|
<%= label_tag "select-all-invoices", "Select All Invioces" %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
<% @customer.invoices.order(id: :desc).each do |invoice| %>
|
<% @customer.invoices.order(id: :desc).each do |invoice| %>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<%= check_box_tag "item_ids[]", invoice.id, false,data: { checkbox_select_all_target: "checkbox", class: "item-checkbox" } %>
|
<%= check_box_tag "invoice_ids[]", invoice.id, false, class: "invoice-checkbox" %>
|
||||||
<b><%= link_to "##{invoice.doc_number}", invoice_path(invoice), target: :_blank %></b> <%= invoice.txn_date %>
|
<b><%= link_to "##{invoice.doc_number}", invoice_path(invoice), target: :_blank %></b> <%= invoice.txn_date %>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -1,23 +1,17 @@
|
|||||||
document.addEventListener("turbo:load", () => {
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
const selectAllBox = document.getElementById("select-all-batches");
|
const select_all_invoice = document.getElementById('select-all-invoices');
|
||||||
const checkboxes = document.querySelectorAll(".item-checkbox");
|
const invoices = document.querySelectorAll('.invoice-checkbox');
|
||||||
|
|
||||||
if (selectAllBox) {
|
if (select_all_invoice) {
|
||||||
selectAllBox.addEventListener("change", function() {
|
select_all_invoice.addEventListener('change', (e) => {
|
||||||
checkboxes.forEach((checkbox) => {
|
invoices.forEach(item => item.checked = e.target.checked);
|
||||||
checkbox.checked = this.checked;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// Optional: Uncheck "Select All" if an individual box is unchecked
|
|
||||||
checkboxes.forEach((checkbox) => {
|
|
||||||
checkbox.addEventListener("change", () => {
|
|
||||||
if (!checkbox.checked) {
|
|
||||||
selectAllBox.checked = false;
|
|
||||||
} else if (Array.from(checkboxes).every(c => c.checked)) {
|
|
||||||
selectAllBox.checked = true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
invoices.forEach(item => {
|
||||||
|
item.addEventListener('change', () => {
|
||||||
|
const allChecked = Array.from(invoices).every(i => i.checked);
|
||||||
|
select_all_invoice.checked = allChecked;
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
Reference in New Issue
Block a user