Skip to content

Commit

Permalink
Merge pull request #2080 from JantBogard/OP-1187
Browse files Browse the repository at this point in the history
OP-1187 | Printing Inventory
  • Loading branch information
mwithi authored Nov 18, 2024
2 parents dcda482 + 6155fc0 commit b5ed784
Show file tree
Hide file tree
Showing 8 changed files with 526 additions and 12 deletions.
3 changes: 2 additions & 1 deletion bundle/language_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,7 @@ angal.hospital.visitduration.txt
angal.hospital.visitendhour.txt = Visit end hour
angal.hospital.visitstarthour.txt = Visit start hour
angal.inventory.allproduct.txt = All products
angal.inventory.askforrealquantityempty.msg = Do you want to print without the real quantity?
angal.inventory.canceled = Canceled
angal.inventory.cannotcreateanotherinventorywithstatusdraft.msg = Cannot create another inventory with status draft, Because you already have an inventory with status draft or validated.
angal.inventory.cannotsavelot.msg = Cannot save the lot. Please verify lot information and retry.
Expand Down Expand Up @@ -1926,4 +1927,4 @@ angal.xmpp.userinfo.fmt.txt
angal.xmpp.usersinfo.border = User's Info
angal.xmpp.wantstosharewithyouthisreport.fmt.msg = \n*** {0} wants to share with you this report: {1}\n
angal.xmpp.wouldliketosend.fmt.msg = {0} would like to send: \n{1}
angal.xmpp.youhaverejectedthefiletransfer.txt = You have rejected the file transfer.
angal.xmpp.youhaverejectedthefiletransfer.txt = You have rejected the file transfer.
Binary file added rpt_base/Inventory.jasper
Binary file not shown.
404 changes: 404 additions & 0 deletions rpt_base/Inventory.jrxml

Large diffs are not rendered by default.

25 changes: 25 additions & 0 deletions rpt_base/Inventory.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#Generated by Eclipse Messages Editor (Eclipse Babel)

Inventory = Inventory

Code = Code

Status = Status

Reference = Reference

InventoryDate = Inventory Date

MainStoreInventoryID = MAIN STORE INVENTORY ID

Designation = Designation

LotCode= Lot Code

DueDate = Due Date

TheoreticQuantity = Theoretic Quantity

RealQuantity = Real Quantity


25 changes: 25 additions & 0 deletions rpt_base/Inventory_en.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#Generated by Eclipse Messages Editor (Eclipse Babel)

Inventory = Inventory

Code = Code

Status = Status

Reference = Reference

InventoryDate = Inventory Date

MainStoreInventoryID = MAIN STORE INVENTORY ID

Designation = Designation

LotCode= Lot Code

DueDate = Due Date

TheoreticQuantity = Theoretic Quantity

RealQuantity = Real Quantity


11 changes: 0 additions & 11 deletions src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ public class InventoryBrowser extends ModalJFrame implements InventoryListener {
private JButton jButtonClose;
private JButton jButtonNew;
private JButton jButtonEdit;
private JButton jButtonPrint;
private JButton jButtonDelete;
private JButton jButtonView;
private JScrollPane scrollPaneInventory;
Expand Down Expand Up @@ -267,7 +266,6 @@ private JPanel getPanelFooter() {
panelFooter.add(getNewButton());
panelFooter.add(getUpdateButton());
panelFooter.add(getViewButton());
panelFooter.add(getPrintButton());
panelFooter.add(getDeleteButton());
panelFooter.add(getCloseButton());
}
Expand Down Expand Up @@ -410,13 +408,6 @@ private JButton getViewButton() {
});
return jButtonView;
}

private JButton getPrintButton() {
jButtonPrint = new JButton(MessageBundle.getMessage("angal.common.print.btn"));
jButtonPrint.setMnemonic(MessageBundle.getMnemonic("angal.common.print.btn.key"));
jButtonPrint.setEnabled(false);
return jButtonPrint;
}

private JButton getDeleteButton() {
jButtonDelete = new JButton(MessageBundle.getMessage("angal.common.delete.btn"));
Expand Down Expand Up @@ -486,12 +477,10 @@ public void valueChanged(ListSelectionEvent e) {
if (selectedRows.length == 1) {
jButtonEdit.setEnabled(true);
jButtonView.setEnabled(true);
jButtonPrint.setEnabled(true);
jButtonDelete.setEnabled(true);
} else {
jButtonEdit.setEnabled(false);
jButtonView.setEnabled(false);
jButtonPrint.setEnabled(false);
jButtonDelete.setEnabled(false);
}
}
Expand Down
24 changes: 24 additions & 0 deletions src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@
import org.isf.medstockmovtype.model.MovementType;
import org.isf.menu.manager.Context;
import org.isf.menu.manager.UserBrowsingManager;
import org.isf.stat.gui.report.GenericReportPharmaceuticalInventory;
import org.isf.stat.manager.JasperReportsManager;
import org.isf.supplier.manager.SupplierBrowserManager;
import org.isf.supplier.model.Supplier;
import org.isf.utils.db.NormalizeString;
Expand Down Expand Up @@ -163,6 +165,7 @@ private void fireInventoryUpdated() {
private JPanel panelFooter;
private JPanel panelContent;
private JButton closeButton;
private JButton printButton;
private JButton deleteButton;
private JButton saveButton;
private JButton resetButton;
Expand Down Expand Up @@ -224,6 +227,7 @@ private void fireInventoryUpdated() {
private MedicalDsrStockMovementTypeBrowserManager movTypeManager = Context.getApplicationContext().getBean(MedicalDsrStockMovementTypeBrowserManager.class);
private SupplierBrowserManager supplierManager = Context.getApplicationContext().getBean(SupplierBrowserManager.class);
private WardBrowserManager wardManager = Context.getApplicationContext().getBean(WardBrowserManager.class);
private JasperReportsManager jasperReportsManager = Context.getApplicationContext().getBean(JasperReportsManager.class);

public InventoryEdit() {
mode = "new";
Expand Down Expand Up @@ -293,6 +297,7 @@ public void windowClosing(WindowEvent e) {
supplierCombo.setEnabled(false);
destinationCombo.setEnabled(false);
lotButton.setVisible(false);
printButton.setVisible(true);
} else {
saveButton.setVisible(true);
validateButton.setVisible(true);
Expand All @@ -308,6 +313,7 @@ public void windowClosing(WindowEvent e) {
supplierCombo.setEnabled(true);
destinationCombo.setEnabled(true);
lotButton.setVisible(true);
printButton.setVisible(false);
}
}

Expand Down Expand Up @@ -451,6 +457,7 @@ private JPanel getPanelFooter() {
panelFooter.add(getDeleteButton());
panelFooter.add(getLotButton());
panelFooter.add(getCleanTableButton());
panelFooter.add(getPrintButton());
panelFooter.add(getCloseButton());
}
return panelFooter;
Expand Down Expand Up @@ -921,6 +928,23 @@ private JButton getCloseButton() {
return closeButton;
}

private JButton getPrintButton() {
printButton = new JButton(MessageBundle.getMessage("angal.common.print.btn"));
printButton.setMnemonic(MessageBundle.getMnemonic("angal.common.print.btn.key"));
printButton.setEnabled(true);

printButton.addActionListener(e -> {
int printRealQty = 0;
int response = MessageDialog.yesNo(this, "angal.inventory.askforrealquantityempty.msg");
if (response == JOptionPane.YES_OPTION) {
printRealQty = 1;
}
new GenericReportPharmaceuticalInventory(inventory, "Inventory", printRealQty);
});

return printButton;
}

private JButton getCleanTableButton() {
resetButton = new JButton(MessageBundle.getMessage("angal.inventory.clean.btn"));
resetButton.setMnemonic(MessageBundle.getMnemonic("angal.inventory.clean.btn.key"));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Open Hospital (www.open-hospital.org)
* Copyright © 2006-2024 Informatici Senza Frontiere ([email protected])
*
* Open Hospital is a free and open source software for healthcare data management.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* https://www.gnu.org/licenses/gpl-3.0-standalone.html
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package org.isf.stat.gui.report;

import org.isf.medicalinventory.model.MedicalInventory;
import org.isf.menu.manager.Context;
import org.isf.stat.dto.JasperReportResultDto;
import org.isf.stat.manager.JasperReportsManager;
import org.isf.utils.jobjects.MessageDialog;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class GenericReportPharmaceuticalInventory extends DisplayReport {

private static final Logger LOGGER = LoggerFactory.getLogger(GenericReportPharmaceuticalInventory.class);
private JasperReportsManager jasperReportsManager = Context.getApplicationContext().getBean(JasperReportsManager.class);

public GenericReportPharmaceuticalInventory(MedicalInventory medicalInventory, String jasperFileName, int printRealQty) {
try {
JasperReportResultDto jasperReportResultDto = jasperReportsManager.getInventoryReportPdf(medicalInventory, jasperFileName, printRealQty);
showReport(jasperReportResultDto);
} catch (Exception e) {
LOGGER.error("", e);
MessageDialog.error(null, "angal.inventory.printing.error.msg");
}
}
}

0 comments on commit b5ed784

Please sign in to comment.