2 /************************************************************************
3 * Mailer v0.2.1-FINAL Start: 05/28/2007 *
4 * =================== Last change: 05/31/2007 *
6 * -------------------------------------------------------------------- *
7 * File : ext-bank.php *
8 * -------------------------------------------------------------------- *
9 * Short description : A little bank account *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Ein einfaches Bankaccount *
12 * -------------------------------------------------------------------- *
15 * $Tag:: 0.2.1-FINAL $ *
17 * Needs to be in all Files and every File needs "svn propset *
18 * svn:keywords Date Revision" (autoprobset!) at least!!!!!! *
19 * -------------------------------------------------------------------- *
20 * Copyright (c) 2003 - 2009 by Roland Haeder *
21 * Copyright (c) 2009, 2010 by Mailer Developer Team *
22 * For more information visit: http://www.mxchange.org *
24 * This program is free software; you can redistribute it and/or modify *
25 * it under the terms of the GNU General Public License as published by *
26 * the Free Software Foundation; either version 2 of the License, or *
27 * (at your option) any later version. *
29 * This program is distributed in the hope that it will be useful, *
30 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
31 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
32 * GNU General Public License for more details. *
34 * You should have received a copy of the GNU General Public License *
35 * along with this program; if not, write to the Free Software *
36 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
38 ************************************************************************/
40 // Some security stuff...
41 if (!defined('__SECURITY')) {
46 setThisExtensionVersion('0.0');
48 // Version history array (add more with , '0.1.0' and so on)
49 setExtensionVersionHistory(array('0.0'));
51 // This extension is in development (non-productive)
52 enableExtensionProductive(false);
54 switch (getExtensionMode()) {
55 case 'register': // Do stuff when installation is running (modules.php?module=admin is called)
56 // SQL commands to run
57 addExtensionSql('DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_bank_accounts`');
58 addExtensionSql("CREATE TABLE `{?_MYSQL_PREFIX?}_bank_accounts` (
59 id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
60 userid BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
61 account_created BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
62 account_locked BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
63 locked_reason TINYTEXT,
64 status ENUM('NEW','ACTIVE','LOCKED') NOT NULL DEFAULT 'NEW',
65 account_balance FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000,
66 output_mode ENUM('LOGIN','EMAIL','DISABLED'),
67 pin VARCHAR(50) NOT NULL DEFAULT '',
68 tan_mode ENUM('NORMAL','INDEXED'),
69 tan_list_status ENUM('PENDING','ACTIVE','INVALID','LOCKED') NOT NULL DEFAULT 'PENDING',
70 tan_key VARCHAR(50) NOT NULL DEFAULT '',
71 month_transfered BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
72 last_tan VARCHAR(5) NOT NULL DEFAULT '00000',
73 last_tan_stamp BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
74 last_tan_purpose TINYTEXT,
75 account_type ENUM('CHECK','SAVING') NOT NULL DEFAULT 'CHECK',
76 overdraft_credit FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000,
79 INDEX `userid_type` (userid, account_type),
80 INDEX (account_created),
81 INDEX (account_locked),
82 INDEX (last_tan_stamp)
83 ) TYPE={?_TABLE_TYPE?}");
84 addExtensionSql('DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_bank_transfers`');
85 addExtensionSql("CREATE TABLE `{?_MYSQL_PREFIX?}_bank_transfers` (
86 id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
87 to_account_id BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
88 from_account_id BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
89 points_amount FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000,
90 day_bookkeeping CHAR(4) NOT NULL DEFAULT '0000',
91 day_available CHAR(4) NOT NULL DEFAULT '0000',
92 transfer_purpose TINYTEXT,
94 INDEX (to_account_id, from_account_id),
95 INDEX (day_bookkeeping, day_available)
96 ) TYPE={?_TABLE_TYPE?}");
97 addExtensionSql('DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_bank_packages`');
98 addExtensionSql("CREATE TABLE `{?_MYSQL_PREFIX?}_bank_packages` (
99 id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
100 title VARCHAR(255) NOT NULL DEFAULT '',
101 description TINYTEXT,
102 account_fee FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000,
103 free_transfers INT(7) UNSIGNED NOT NULL DEFAULT 0,
104 transfer_fee FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000,
105 available TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
106 output_system_mode ENUM('LOGIN','EMAIL','DISABLED'),
107 package_active ENUM('Y','N') NOT NULL DEFAULT 'N',
108 free_months_no_fee TINYINT(3) UNSIGNED NOT NULL DEFAULT 0,
109 interest_plus FLOAT(7,5) UNSIGNED NOT NULL DEFAULT 0.00000,
110 interest_minus FLOAT(7,5) UNSIGNED NOT NULL DEFAULT 0.00000,
111 first_payment FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000,
112 free_account_income FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000,
113 free_account_stuff TINYTEXT null,
114 tan_lock TINYINT(3) UNSIGNED NOT NULL DEFAULT 0,
116 ) TYPE={?_TABLE_TYPE?}");
117 // free_account_stuff will be a list of columns of the table _bank_packages
118 // what the member shall get for the specified income. output_system_mode
119 // must be extended with the mode you get for free: output_system_mode:LOGIN
120 // should be fine. More than one entry and not DISABLED ;) are not supported.
121 addExtensionSql('DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_bank_tanlist`');
122 addExtensionSql("CREATE TABLE `{?_MYSQL_PREFIX?}_bank_tanlist` (
123 id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
124 idx TINYINT(3) UNSIGNED NOT NULL DEFAULT 0,
125 account_id BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
126 tan VARCHAR(50) NOT NULL DEFAULT '',
127 used ENUM('Y','N') NOT NULL DEFAULT 'N',
129 UNIQUE (account_id, tan)
130 ) TYPE={?_TABLE_TYPE?}");
132 // Admin menu queries
133 addAdminMenuSql('bank', NULL, 'Bank-Accounts','Verwalten Sie hier alle Bank-Accounts Ihrer Mitglieder, sowie Angebotspakete und Überweisungen.', 6);
134 addAdminMenuSql('bank','add_bank_package','Angebotspaket hinzufügen','Neues Angebotspaket erstellen.', 1);
135 addAdminMenuSql('bank','list_bank_package','Angebotspakete auflisten','Listet alle erstellten Angebotspakete auf.', 2);
136 addAdminMenuSql('bank','edit_bank_package','Angebotspaket ändern','Nach Auswahl eines Angebotspaketes können Sie dieses hier verändern. Bitte beachten Sie, dass Ihre Mitglieder keine Mail dabei erhalten!', 3);
137 addAdminMenuSql('bank','lock_bank_package','Angebotspaket ent-/sperren','Nehmen Sie Angebotspakete zur temporären Überarbeitung zuvor heraus, dann können Sie in Ruhe drüber nachdenken und Berechnungen anstellen. Freigabe ist hier auch möglich.', 4);
138 addAdminMenuSql('bank','del_bank_package','Angebotspaket löschen','Nach Auswahl eines Angebotspaketes können Sie mit abschliessender Bestätigung Angebotspakete ganz löschen. Bitte beachten Sie, dass dies nur möglich ist, wenn auch alle Accounts dieses nicht mehr nutzen!', 5);
139 addAdminMenuSql('bank','add_bank_account','Konto anlegen','Legen Sie hier Konten für die Mitglieder an (falls Ihre Mitglieder nicht zurecht kommen).', 6);
140 addAdminMenuSql('bank','list_bank_account','Konten auflisten','Auflistung aller Konto oder eines auswählbaren Mitglieds.', 7);
141 addAdminMenuSql('bank','edit_bank_account','Konto ändern','Ändern Sie hier bestehende Konten, z.B. den Dispositionskredit usw. PINs und TANs sind hier nicht änderbar! Bestätigungsmails sind optional versendbar.', 8);
142 addAdminMenuSql('bank','lock_bank_account','Konto ent-/sperren','Sperren Sie hier Konten bei Bedarf. Auch das Freischalten ist hier möglich. Eine Benachrichtigung per Mail wird dann an das Mitglied ausgesendet.', 9);
143 addAdminMenuSql('bank','del_bank_account','Konto löschen','Löschen von Konten mit Bestätigungsmail. Wenn Sie ein Mitglieder-Account löschen, so müssen Sie derzeit seine angelegten Konten auch löschen!', 10);
144 addAdminMenuSql('bank','send_bank_tanlist','TAN-Liste aussenden','Listet zuerst Anfragen von Mitgliedern auf, die eine neue (i)TAN-Liste benötigen, anschliessend kann die Liste dann ausgesendet werden.', 11);
145 addAdminMenuSql('bank','lock_bank_tanlist','TAN-Liste ent-/sperren','Bestehende TAN-Listen können auf Kundenwunsch hin gesperrt und wieder entsperrt werden. Dies passiert auch, wenn der Kunde x-mal (siehe Angebotspakete) eine verkehrte TAN eingegeben hat. Einzelne TANs sind nicht ent-/sperrbar.', 12);
146 addAdminMenuSql('bank','list_bank_trans','Überweisungen auflisten','Nach Auswahl eines Mitgliedes und einem Konto (benötgt JavaScript!) können Sie seitenweise die Überweisungen durchschauen.', 13);
149 addMemberMenuSql('bank', NULL, 'Bank-Account','N','Y', 3);
150 addMemberMenuSql('bank','bank_infos','Angebotspakete','N','Y', 1);
151 addMemberMenuSql('bank','bank_create','Konto anlegen','N','Y', 2);
152 addMemberMenuSql('bank','bank_deposit','Auf Konto einzahlen','N','Y', 3);
153 addMemberMenuSql('bank','bank_withdraw','Vom Konto abheben','N','Y', 4);
154 addMemberMenuSql('bank','bank_output','Kontoauszug','N','Y', 5);
155 addMemberMenuSql('bank','bank_change','Paket wechseln','N','Y', 6);
156 addMemberMenuSql('bank','bank_remove','Konto Kündigen','N','Y', 7);
159 case 'remove': // Do stuff when removing extension
160 // SQL commands to run
161 addExtensionSql('DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_bank_accounts`');
162 addExtensionSql('DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_bank_transfers`');
163 addExtensionSql('DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_bank_packages`');
164 addExtensionSql('DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_bank_tanlist`');
165 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE `action`='bank'");
166 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE `action`='bank'");
169 case 'activate': // Do stuff when admin activates this extension
170 // SQL commands to run
171 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `visible`='Y', `locked`='N' WHERE `action`='bank' LIMIT 8");
174 case 'deactivate': // Do stuff when admin deactivates this extension
175 // SQL commands to run
176 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `visible`='N', `locked`='Y' WHERE `action`='bank' LIMIT 8");
179 case 'update': // Update an extension
180 switch (getCurrentExtensionVersion()) {
181 case '0.0.1': // SQL queries for v0.0.1
184 // Update notes (these will be set as task text!)
185 setExtensionUpdateNotes('');
190 case 'modify': // When the extension got modified
193 case 'test': // For testing purposes. For details see file inc/modules/admin/what-extensions.php, arround line 305.
196 case 'init': // Do stuff when extension is initialized
199 default: // Unknown extension mode
200 logDebugMessage(__FILE__, __LINE__, sprintf("Unknown extension mode %s in extension %s detected.", getExtensionMode(), getCurrentExtensionName()));