1 /*******************************************************
2  Copyright (C) 2006 Madhan Kanagavel
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or
7  (at your option) any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program; if not, write to the Free Software
16  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17  ********************************************************/
18 
19 #ifndef MM_EX_BILLSDEPOSITSPANEL_H_
20 #define MM_EX_BILLSDEPOSITSPANEL_H_
21 
22 #include "filtertransdialog.h"
23 #include "mmpanelbase.h"
24 #include "model/Model_Billsdeposits.h"
25 #include <vector>
26 
27 class wxListEvent;
28 class mmBillsDepositsPanel;
29 
30 /* Custom ListCtrl class that implements virtual LC style */
31 class billsDepositsListCtrl: public mmListCtrl
32 {
33     DECLARE_NO_COPY_CLASS(billsDepositsListCtrl)
34     wxDECLARE_EVENT_TABLE();
35 
36 public:
37     billsDepositsListCtrl(mmBillsDepositsPanel* bdp, wxWindow *parent, wxWindowID winid = wxID_ANY);
38     ~billsDepositsListCtrl();
39 
40     void OnNewBDSeries(wxCommandEvent& event);
41     void OnEditBDSeries(wxCommandEvent& event);
42     void OnDeleteBDSeries(wxCommandEvent& event);
43     void OnEnterBDTransaction(wxCommandEvent& event);
44     void OnSkipBDTransaction(wxCommandEvent& event);
45     void OnOpenAttachment(wxCommandEvent& event);
46     void OnOrganizeAttachments(wxCommandEvent& event);
47     void RefreshList();
48 
49 protected:
50     virtual void OnColClick(wxListEvent& event);
51 
52 private:
53     /* required overrides for virtual style list control */
54     virtual wxString OnGetItemText(long item, long column) const;
55     virtual int OnGetItemImage(long item) const;
56 
57     void OnItemRightClick(wxMouseEvent& event);
58     void OnListLeftClick(wxMouseEvent& event);
59     void OnListItemActivated(wxListEvent& event);
60     void OnMarkTransaction(wxCommandEvent& event);
61     void OnMarkAllTransactions(wxCommandEvent& event);
62     void OnListKeyDown(wxListEvent& event);
63     void OnListItemSelected(wxListEvent& event);
64 
65     void refreshVisualList(int selected_index = -1);
66 
67     mmBillsDepositsPanel* m_bdp;
68 };
69 
70 class mmBillsDepositsPanel : public mmPanelBase
71 {
72     wxDECLARE_EVENT_TABLE();
73 
74 public:
75     mmBillsDepositsPanel(wxWindow *parent
76         , wxWindowID winid = wxID_ANY
77         , const wxPoint& pos = wxDefaultPosition
78         , const wxSize& size = wxDefaultSize
79         , long style = wxTAB_TRAVERSAL | wxNO_BORDER
80         , const wxString& name = wxPanelNameStr
81     );
82     ~mmBillsDepositsPanel();
83 
84     /* Helper Functions/data */
85     Model_Billsdeposits::Full_Data_Set bills_;
86     void updateBottomPanelData(int selIndex);
87     void enableEditDeleteButtons(bool en);
88     /* updates the Repeating transactions panel data */
89     int initVirtualListControl(int id = -1);
90     /* Getter for Virtual List Control */
91     wxString getItem(long item, long column);
92     void RefreshList();
getColumnsNumber()93     int getColumnsNumber() { return COL_MAX; }
col_sort()94     int col_sort() { return COL_PAYMENT_DATE; }
95 
96     static wxString GetFrequency(const Model_Billsdeposits::Data* item);
97     static wxString GetRemainingDays(const Model_Billsdeposits::Data* item);
98 
99     wxString BuildPage() const;
100 
101 private:
102     void CreateControls();
103     bool Create(wxWindow *parent, wxWindowID winid,
104         const wxPoint& pos = wxDefaultPosition,
105         const wxSize& size = wxDefaultSize,
106         long style = wxTAB_TRAVERSAL | wxNO_BORDER,
107         const wxString& name = wxPanelNameStr);
108 
109     /* Event handlers for Buttons */
110     void OnNewBDSeries(wxCommandEvent& event);
111     void OnEditBDSeries(wxCommandEvent& event);
112     void OnDeleteBDSeries(wxCommandEvent& event);
113 
114     void OnEnterBDTransaction(wxCommandEvent& event);
115     void OnSkipBDTransaction(wxCommandEvent& event);
116     void OnOpenAttachment(wxCommandEvent& event);
117 
118     void OnViewPopupSelected(wxCommandEvent& event);
119 
120     void sortTable();
121     wxString tips();
122 
123 private:
124     wxImageList* m_imageList;
125     billsDepositsListCtrl* listCtrlAccount_;
126     wxStaticText* m_infoText;
127     wxStaticText* m_infoTextMini;
128 
129     enum EColumn
130     {
131         COL_ICON = 0,
132         COL_ID,
133         COL_PAYMENT_DATE,
134         COL_DUE_DATE,
135         COL_ACCOUNT,
136         COL_PAYEE,
137         COL_STATUS,
138         COL_CATEGORY,
139         COL_TYPE,
140         COL_AMOUNT,
141         COL_FREQUENCY,
142         COL_REPEATS,
143         COL_AUTO,
144         COL_DAYS,
145         COL_NUMBER,
146         COL_NOTES,
147         COL_MAX, // number of columns
148     };
149 
150     bool transFilterActive_;
151     void OnFilterTransactions(wxMouseEvent& event);
152     mmFilterTransactionsDialog* transFilterDlg_;
153     wxStaticBitmap* bitmapTransFilter_;
154 
155     wxArrayString tips_;
156 };
157 #endif
158 
159