1 /******************************************************* 2 Copyright (C) 2006 Madhan Kanagavel 3 Copyright (C) 2011, 2012 Stefano Giorgio 4 Copyright (C) 2013, 2014 Nikolay 5 6 This program is free software; you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation; either version 2 of the License, or 9 (at your option) any later version. 10 11 This program is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with this program; if not, write to the Free Software 18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 ********************************************************/ 20 21 #ifndef MM_EX_CHECKINGPANEL_H_ 22 #define MM_EX_CHECKINGPANEL_H_ 23 //---------------------------------------------------------------------------- 24 #include "filtertransdialog.h" 25 #include "mmpanelbase.h" 26 #include "reports/mmDateRange.h" 27 #include "model/Model_Checking.h" 28 #include "model/Model_Account.h" 29 #include <map> 30 //---------------------------------------------------------------------------- 31 class mmCheckingPanel; 32 class mmFilterTransactionsDialog; 33 class mmGUIFrame; 34 //---------------------------------------------------------------------------- 35 36 class TransactionListCtrl : public mmListCtrl 37 { 38 public: 39 40 TransactionListCtrl(mmCheckingPanel *cp, wxWindow *parent 41 , const wxWindowID id); 42 43 ~TransactionListCtrl(); 44 45 void createColumns(mmListCtrl &lst); 46 enum EIcons //m_imageList 47 { 48 ICON_RECONCILED, 49 ICON_VOID, 50 ICON_FOLLOWUP, 51 ICON_NONE, 52 ICON_DESC, 53 ICON_ASC, 54 ICON_DUPLICATE, 55 ICON_TRASH 56 }; 57 58 enum EColumn 59 { 60 COL_IMGSTATUS = 0, 61 COL_ID, 62 COL_DATE, 63 COL_NUMBER, 64 COL_PAYEE_STR, 65 COL_STATUS, 66 COL_CATEGORY, 67 COL_WITHDRAWAL, 68 COL_DEPOSIT, 69 COL_BALANCE, 70 COL_NOTES, 71 COL_MAX, // number of columns 72 COL_DEF_SORT = COL_DATE 73 }; toEColumn(long col)74 EColumn toEColumn(long col) 75 { 76 EColumn res = COL_DEF_SORT; 77 if (col >= 0 && col < COL_MAX) res = static_cast<EColumn>(col); 78 79 return res; 80 } 81 82 EColumn g_sortcol; // index of column to sort 83 bool g_asc; // asc\desc sorting 84 getSortOrder()85 bool getSortOrder() const { return m_asc; } getSortColumn()86 EColumn getSortColumn() const { return m_sortCol; } 87 setSortOrder(bool asc)88 void setSortOrder(bool asc) { m_asc = asc; } setSortColumn(EColumn col)89 void setSortColumn(EColumn col) { m_sortCol = col; } 90 91 void setColumnImage(EColumn col, int image); 92 93 void OnNewTransaction(wxCommandEvent& event); 94 void OnDeleteTransaction(wxCommandEvent& event); 95 void OnEditTransaction(wxCommandEvent& event); 96 void OnDuplicateTransaction(wxCommandEvent& event); 97 void OnSetUserColour(wxCommandEvent& event); 98 void OnMoveTransaction(wxCommandEvent& event); 99 void OnOpenAttachment(wxCommandEvent& event); 100 /// Displays the split categories for the selected transaction 101 void OnViewSplitTransaction(wxCommandEvent& event); 102 void OnOrganizeAttachments(wxCommandEvent& event); 103 void OnCreateReoccurance(wxCommandEvent& event); 104 long m_selectedIndex; 105 long m_selectedForCopy; //The transaction ID if selected for copy 106 long m_selectedID; //Selected transaction ID 107 void refreshVisualList(int trans_id = -1, bool filter = true); 108 bool showDeletedTransactions_; 109 110 protected: 111 /* Sort Columns */ 112 virtual void OnColClick(wxListEvent& event); 113 114 private: 115 enum 116 { 117 MENU_TREEPOPUP_SHOWTRASH = wxID_HIGHEST + 150, 118 MENU_TREEPOPUP_MARKRECONCILED, 119 MENU_TREEPOPUP_MARKUNRECONCILED, 120 MENU_TREEPOPUP_MARKVOID, 121 MENU_TREEPOPUP_MARK_ADD_FLAG_FOLLOWUP, 122 MENU_TREEPOPUP_MARKDUPLICATE, 123 MENU_TREEPOPUP_MARKDELETE, 124 MENU_TREEPOPUP_MARKRECONCILED_ALL, 125 MENU_TREEPOPUP_MARKUNRECONCILED_ALL, 126 MENU_TREEPOPUP_MARKVOID_ALL, 127 MENU_TREEPOPUP_MARK_ADD_FLAG_FOLLOWUP_ALL, 128 MENU_TREEPOPUP_MARKDUPLICATE_ALL, 129 MENU_TREEPOPUP_DELETE_VIEWED, 130 MENU_TREEPOPUP_DELETE_FLAGGED, 131 MENU_TREEPOPUP_DELETE_UNRECONCILED, 132 133 MENU_TREEPOPUP_VIEW_SPLIT_CATEGORIES, 134 MENU_TREEPOPUP_ORGANIZE_ATTACHMENTS, 135 MENU_TREEPOPUP_CREATE_REOCCURANCE, 136 MENU_SUBMENU_MARK_ALL, 137 138 MENU_VIEW_, 139 MENU_VIEW_DELETE_TRANS, 140 MENU_VIEW_DELETE_FLAGGED, 141 142 MENU_ON_COPY_TRANSACTION, 143 MENU_ON_PASTE_TRANSACTION, 144 MENU_ON_NEW_TRANSACTION, 145 MENU_ON_DUPLICATE_TRANSACTION, 146 147 MENU_ON_SET_UDC0, //Default colour 148 MENU_ON_SET_UDC1, //User defined colour 1 149 MENU_ON_SET_UDC2, //User defined colour 2 150 MENU_ON_SET_UDC3, //User defined colour 3 151 MENU_ON_SET_UDC4, //User defined colour 4 152 MENU_ON_SET_UDC5, //User defined colour 5 153 MENU_ON_SET_UDC6, //User defined colour 6 154 MENU_ON_SET_UDC7, //User defined colour 7 155 156 MENU_TREEPOPUP_NEW2, 157 MENU_TREEPOPUP_EDIT2, 158 MENU_TREEPOPUP_MOVE2, 159 MENU_TREEPOPUP_DELETE2, 160 ID_PANEL_CHECKING_STATIC_BITMAP_VIEW, 161 }; 162 163 DECLARE_NO_COPY_CLASS(TransactionListCtrl) 164 wxDECLARE_EVENT_TABLE(); 165 166 mmCheckingPanel *m_cp; 167 168 wxListItemAttr m_attr1; // style1 169 wxListItemAttr m_attr2; // style2 170 wxListItemAttr m_attr3; // style, for future dates 171 wxListItemAttr m_attr4; // style, for future dates 172 wxListItemAttr m_attr11; // user defined style 1 173 wxListItemAttr m_attr12; // user defined style 2 174 wxListItemAttr m_attr13; // user defined style 3 175 wxListItemAttr m_attr14; // user defined style 4 176 wxListItemAttr m_attr15; // user defined style 5 177 wxListItemAttr m_attr16; // user defined style 6 178 wxListItemAttr m_attr17; // user defined style 7 179 180 EColumn m_sortCol; 181 182 /* required overrides for virtual style list control */ 183 virtual wxString OnGetItemText(long item, long column) const; 184 virtual int OnGetItemColumnImage(long item, long column) const; 185 virtual wxListItemAttr *OnGetItemAttr(long item) const; 186 187 void OnMouseRightClick(wxMouseEvent& event); 188 void OnListLeftClick(wxMouseEvent& event); 189 void OnListItemSelected(wxListEvent& event); 190 void OnListItemActivated(wxListEvent& event); 191 void OnMarkTransaction(wxCommandEvent& event); 192 void OnShowChbClick(wxCommandEvent& /*event*/); 193 void OnMarkAllTransactions(wxCommandEvent& event); 194 void OnListKeyDown(wxListEvent& event); 195 void OnChar(wxKeyEvent& event); 196 void OnCopy(wxCommandEvent& WXUNUSED(event)); 197 void OnPaste(wxCommandEvent& WXUNUSED(event)); 198 int OnPaste(Model_Checking::Data* tran); 199 200 /* The topmost visible item - this will be used to set 201 where to display the list again after refresh */ 202 long topItemIndex_; 203 }; 204 205 //---------------------------------------------------------------------------- 206 207 class mmCheckingPanel : public mmPanelBase 208 { 209 public: 210 211 mmCheckingPanel(wxWindow *parent 212 , mmGUIFrame *frame 213 , int accountID 214 , int id = wxID_ANY 215 ); 216 217 ~mmCheckingPanel(); 218 219 /// Display the split categories for the selected transaction. 220 void DisplaySplitCategories(int transID); 221 /// Refresh account screen with new details 222 void DisplayAccountDetails(int accountID); 223 224 void SetSelectedTransaction(int transID); 225 226 void RefreshList(int transID = -1); 227 228 wxString BuildPage() const; 229 230 private: 231 enum 232 { 233 ID_PANEL_CHECKING_STATIC_BALHEADER1 = wxID_HIGHEST + 50, 234 ID_PANEL_CHECKING_STATIC_BALHEADER2, 235 ID_PANEL_CHECKING_STATIC_BALHEADER3, 236 ID_PANEL_CHECKING_STATIC_BALHEADER4, 237 ID_PANEL_CHECKING_STATIC_BALHEADER5, 238 ID_PANEL_CHECKING_STATIC_DETAILS, 239 ID_PANEL_CHECKING_STATIC_BITMAP_FILTER, 240 }; 241 enum menu 242 { 243 MENU_VIEW_ALLTRANSACTIONS = 0, 244 MENU_VIEW_TODAY, 245 MENU_VIEW_CURRENTMONTH, 246 MENU_VIEW_LAST30, 247 MENU_VIEW_LAST90, 248 MENU_VIEW_LASTMONTH, 249 MENU_VIEW_LAST3MONTHS, 250 MENU_VIEW_LAST12MONTHS, 251 MENU_VIEW_CURRENTYEAR, 252 }; menu_labels()253 static wxArrayString menu_labels() 254 { 255 wxArrayString items; 256 items.Add(wxTRANSLATE("View All Transactions")); 257 items.Add(wxTRANSLATE("View Today")); 258 items.Add(wxTRANSLATE("View Current Month")); 259 items.Add(wxTRANSLATE("View Last 30 days")); 260 items.Add(wxTRANSLATE("View Last 90 days")); 261 items.Add(wxTRANSLATE("View Last Month")); 262 items.Add(wxTRANSLATE("View Last 3 Months")); 263 items.Add(wxTRANSLATE("View Last 12 Months")); 264 items.Add(wxTRANSLATE("View Current Year")); 265 return items; 266 } 267 wxDECLARE_EVENT_TABLE(); 268 friend class TransactionListCtrl; // needs access to m_core, initdb_, ... 269 270 wxButton* btnNew_; 271 wxButton* btnEdit_; 272 wxButton* btnDuplicate_; 273 wxButton* btnDelete_; 274 wxButton* btnAttachment_; 275 wxStaticText* header_text_; 276 wxStaticText* info_panel_; 277 wxStaticText* info_panel_mini_; 278 wxStaticText* stxtMainFilter_; 279 wxStaticText* statTextTransFilter_; 280 wxStaticBitmap* bitmapTransFilter_; 281 wxStaticBitmap* bitmapMainFilter_; 282 mmFilterTransactionsDialog* transFilterDlg_; 283 284 int currentView_; 285 int m_AccountID; 286 int m_basecurrecyID; 287 wxDateTime quickFilterBeginDate_; 288 wxDateTime quickFilterEndDate_; 289 bool transFilterActive_; 290 double filteredBalance_; 291 double account_balance_; 292 double reconciled_balance_; 293 294 TransactionListCtrl *m_listCtrlAccount; 295 Model_Account::Data* m_account; 296 Model_Currency::Data* m_currency; 297 wxScopedPtr<wxImageList> m_imageList; 298 Model_Checking::Full_Data_Set m_trans; 299 300 void initViewTransactionsHeader(); 301 void initFilterSettings(); 302 void setAccountSummary(); 303 void sortTable(); 304 void filterTable(); 305 void updateTable(); 306 void markSelectedTransaction(int trans_id); 307 void CreateControls(); 308 309 bool Create( 310 wxWindow *parent, 311 wxWindowID winid, 312 const wxPoint& pos = wxDefaultPosition, 313 const wxSize& size = wxDefaultSize, 314 long style = wxTAB_TRAVERSAL | wxNO_BORDER, 315 const wxString& name = wxPanelNameStr 316 ); 317 void enableEditDeleteButtons(bool en); 318 319 void OnNewTransaction(wxCommandEvent& event); 320 void OnDeleteTransaction(wxCommandEvent& event); 321 void OnEditTransaction(wxCommandEvent& event); 322 void OnDuplicateTransaction(wxCommandEvent& event); 323 void OnMoveTransaction(wxCommandEvent& event); 324 void OnOpenAttachment(wxCommandEvent& event); 325 void OnMouseLeftDown( wxMouseEvent& event ); 326 void OnViewPopupSelected(wxCommandEvent& event); 327 void OnFilterTransactions(wxMouseEvent& event); 328 void OnSearchTxtEntered(wxCommandEvent& event); 329 void OnFilterResetToViewAll(wxMouseEvent& event); 330 331 void DeleteViewedTransactions(); 332 void DeleteFlaggedTransactions(const wxString& status); 333 void SetTransactionFilterState(bool active); 334 335 /* updates the checking panel data */ 336 void showTips(); 337 void updateExtraTransactionData(int selIndex); 338 wxString GetPanelTitle(const Model_Account::Data& account) const; 339 340 /* Getter for Virtual List Control */ 341 const wxString getItem(long item, long column); 342 343 private: 344 static void mmPlayTransactionSound(); 345 private: 346 mmGUIFrame *m_frame; 347 }; 348 //---------------------------------------------------------------------------- 349 #endif // MM_EX_CHECKINGPANEL_H_ 350 //---------------------------------------------------------------------------- 351 352