Utility.retrieveStationerySettings();
try {
- UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
+ UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) {
Logger.getLogger(Habeas.class.getName()).log(Level.SEVERE, null, ex);
}
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="menuAwaitingPaymentActionPerformed"/>
</Events>
</MenuItem>
+ <MenuItem class="javax.swing.JMenuItem" name="menuNoticesSentNotYetDelivered">
+ <Properties>
+ <Property name="mnemonic" type="int" value="115"/>
+ <Property name="text" type="java.lang.String" value="Notices sent not yet delivered..."/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="menuNoticesSentNotYetDeliveredActionPerformed"/>
+ </Events>
+ </MenuItem>
</SubComponents>
</Menu>
</SubComponents>
package habeas;
import java.util.ArrayList;
-import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
-import javax.swing.filechooser.FileFilter;
-import javax.swing.filechooser.FileNameExtensionFilter;
/**
*
menuGenerateRaisedBills = new javax.swing.JMenuItem();
menuNoticesReports = new javax.swing.JMenu();
menuAwaitingPayment = new javax.swing.JMenuItem();
+ menuNoticesSentNotYetDelivered = new javax.swing.JMenuItem();
menuSettings = new javax.swing.JMenu();
menuDatabaseSettings = new javax.swing.JMenuItem();
menuStationery = new javax.swing.JMenuItem();
});
menuNoticesReports.add(menuAwaitingPayment);
+ menuNoticesSentNotYetDelivered.setMnemonic('s');
+ menuNoticesSentNotYetDelivered.setText("Notices sent not yet delivered...");
+ menuNoticesSentNotYetDelivered.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ menuNoticesSentNotYetDeliveredActionPerformed(evt);
+ }
+ });
+ menuNoticesReports.add(menuNoticesSentNotYetDelivered);
+
menuLawyerNotices.add(menuNoticesReports);
jMenuBar1.add(menuLawyerNotices);
// TODO add your handling code here:
NoticesReportViewDialog frm = new NoticesReportViewDialog(this, false);
String [] cols = {"Reference Number", "Description", "Bill Date", "Bill Amount", "Client"};
- ArrayList<Object> data = Utility.getPendingPaymentBills (-1);
+ int rep = 0;
+ ArrayList<Object> data = Utility.getReportData(rep, -1);
if (data == null) {
JOptionPane.showMessageDialog(this, ERROR_DISPLAYING_REPORT);
return;
}
- frm.setupReportTable(REPORT_TITLE_BILLS_AWAITING_PAYMENT, cols, data);
+ frm.setupReportTable(rep, REPORT_TITLE_BILLS_AWAITING_PAYMENT, cols, data);
frm.setVisible(true);
}//GEN-LAST:event_menuAwaitingPaymentActionPerformed
- private static final String ERROR_DISPLAYING_REPORT = "Error displaying report";
- private static final String REPORT_TITLE_BILLS_AWAITING_PAYMENT = "Bills Awaiting Payment";
+
+ private void menuNoticesSentNotYetDeliveredActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuNoticesSentNotYetDeliveredActionPerformed
+ // TODO add your handling code here:
+ NoticesReportViewDialog frm = new NoticesReportViewDialog(this, false);
+ String[] cols = {"Reference Number", "Description", "Sent Date", "RPAD Reference", "Client"};
+ int rep = 1;
+ ArrayList<Object> data = Utility.getReportData (rep, -1);
+ if (data == null) {
+ JOptionPane.showMessageDialog(this, ERROR_DISPLAYING_REPORT);
+ return;
+ }
+ frm.setupReportTable(rep, REPORT_TITLE_NOTICES_SENT_NOT_DELIVERED, cols, data);
+ frm.setVisible (true);
+ }//GEN-LAST:event_menuNoticesSentNotYetDeliveredActionPerformed
+ public static final String REPORT_TITLE_NOTICES_SENT_NOT_DELIVERED = "Notices Sent Not Yet Delivered";
+ public static final String ERROR_DISPLAYING_REPORT = "Error displaying report";
+ public static final String REPORT_TITLE_BILLS_AWAITING_PAYMENT = "Bills Awaiting Payment";
/**
* @param args the command line arguments
private javax.swing.JMenuItem menuManageNotices;
private javax.swing.JMenu menuMaster;
private javax.swing.JMenu menuNoticesReports;
+ private javax.swing.JMenuItem menuNoticesSentNotYetDelivered;
private javax.swing.JMenu menuSettings;
private javax.swing.JMenuItem menuStationery;
// End of variables declaration//GEN-END:variables
package habeas;
import java.awt.Frame;
-import java.awt.event.MouseAdapter;
-import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.Date;
import javax.swing.JOptionPane;
import java.util.ArrayList;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
-import javax.swing.JTable;
import javax.swing.filechooser.FileFilter;
import javax.swing.filechooser.FileNameExtensionFilter;
import javax.swing.table.DefaultTableModel;
-import javax.swing.table.TableModel;
/**
*
*/
public class NoticesReportViewDialog extends javax.swing.JDialog {
+ private int currentReport;
private String reportTitle;
private String[] reportCols;
private ArrayList<Object> reportData;
private void buttonApplyActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonApplyActionPerformed
// TODO add your handling code here:
if (! checkFilterByClient.isSelected()) {
- reportData = Utility.getPendingPaymentBills(-1);
- if (reportData != null)
+ reportData = Utility.getReportData(currentReport, -1);
+
+ if (reportData != null)
populateReport();
} else {
DBItem db = (DBItem)comboClients.getSelectedItem();
if (db == null)
return;
int selid = db.getKey();
- reportData = Utility.getPendingPaymentBills(selid);
+ reportData = Utility.getReportData(currentReport, selid);
if (reportData != null)
populateReport();
}
private javax.swing.JTable tableReport;
// End of variables declaration//GEN-END:variables
- public void setupReportTable(String title, String[] columns,
+ public void setupReportTable(int reportNum, String title, String[] columns,
ArrayList<Object> data) {
+ currentReport = reportNum;
reportTitle = title;
reportCols = columns;
reportData = data;
*/
package habeas;
-import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.text.DateFormat;
import java.text.MessageFormat;
import java.text.SimpleDateFormat;
-import java.util.Arrays;
import java.util.logging.Level;
import java.util.logging.Logger;
-import jdk.dynalink.linker.support.Guards;
/**
*
* @author hari
*/
public class Utility {
+
+ private static final String[] REPORTS_UNFILTERED = { "SELECT ReferenceNumber, Description"
+ + ", BillDate, BillAmount, ClientName FROM legalnotices INNER JOIN "
+ + "clients ON ClientId=clients.id WHERE BillStatus='AWAITING PAYMENT';",
+
+ "SELECT ReferenceNumber, Description, SentDate, RPADReference, "
+ + "ClientName FROM legalnotices INNER JOIN clients ON ClientId=clients.id"
+ + " WHERE NoticeSent=1 AND NoticeDelivered=0;"
+ } ;
+
+ private static final String[] REPORTS_FILTERED = { "SELECT ReferenceNumber, Description"
+ + ", BillDate, BillAmount, ClientName FROM legalnotices INNER JOIN "
+ + "clients ON ClientId=clients.id WHERE BillStatus='AWAITING PAYMENT' "
+ + "AND ClientId=?;",
+
+ "SELECT ReferenceNumber, Description, SentDate, RPADReference, "
+ + "ClientName FROM legalnotices INNER JOIN clients ON ClientId=clients.id"
+ + " WHERE NoticeSent=1 AND NoticeDelivered=0 AND ClientId=?;"
+ } ;
static void saveStationerySettings (String left_header,
String right_header, String signatory) {
}
- static ArrayList<Object> getPendingPaymentBills(int clientid) {
+ static ArrayList<Object> getReportData(int report_num, int clientid) {
ArrayList<Object> data = new ArrayList<>();
try {
Connection conn = DriverManager.getConnection(JDBC + connectionURL);
ResultSet rs;
if (clientid == -1) {
Statement st = conn.createStatement();
- rs = st.executeQuery("SELECT ReferenceNumber, Description, "
- + "BillDate, BillAmount, ClientName"
- + " FROM legalnotices INNER JOIN clients ON ClientId=clients.id "
- + "WHERE BillStatus='AWAITING PAYMENT';");
+ rs = st.executeQuery(REPORTS_UNFILTERED[report_num]);
}
else {
- PreparedStatement st = conn.prepareStatement("SELECT ReferenceNumber, "
- + "Description, BillDate, BillAmount, ClientName"
- + " FROM legalnotices INNER JOIN clients ON ClientId=clients.id "
- + "WHERE BillStatus='AWAITING PAYMENT' AND ClientId=?;");
+ PreparedStatement st = conn.prepareStatement(REPORTS_FILTERED[report_num]);
st.setInt (1, clientid);
rs = st.executeQuery();
}
- DateFormat fmt = new SimpleDateFormat ("dd/MM/yyyy");
+
while (rs.next()) {
- data.add (rs.getString("ReferenceNumber"));
- data.add (rs.getString("Description"));
- data.add (fmt.format (getValidDate(rs, "BillDate")));
- data.add (rs.getInt ("BillAmount"));
- data.add (rs.getString("ClientName"));
+ ResultSetMetaData md = rs.getMetaData();
+ SimpleDateFormat fmt = new SimpleDateFormat ("dd MMM yyyy");
+ for (int i = 1; i <= md.getColumnCount(); i ++ ) {
+ // for INTEGER Columns which are date alone, handle separately
+ if (md.getColumnName(i).contains("Date"))
+ data.add (fmt.format(getValidDate(rs, md.getColumnName(i))));
+ else
+ data.add (rs.getObject (i));
+ }
}
conn.close ();
return data;
else
return String.format("\"%s\"", bareStr.toString());
}
+
+
public Utility () {
}