2 /************************************************************************
3 * MXChange v0.2.1 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 * -------------------------------------------------------------------- *
14 * -------------------------------------------------------------------- *
15 * Copyright (c) 2003 - 2008 by Roland Haeder *
16 * For more information visit: http://www.mxchange.org *
18 * This program is free software; you can redistribute it and/or modify *
19 * it under the terms of the GNU General Public License as published by *
20 * the Free Software Foundation; either version 2 of the License, or *
21 * (at your option) any later version. *
23 * This program is distributed in the hope that it will be useful, *
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
26 * GNU General Public License for more details. *
28 * You should have received a copy of the GNU General Public License *
29 * along with this program; if not, write to the Free Software *
30 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
32 ************************************************************************/
34 // Some security stuff...
35 if (!defined('__SECURITY')) {
36 $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
43 // Auto-set extension version
44 if (!isset($EXT_VER)) $EXT_VER = $EXT_VERSION;
46 // Version history array (add more with , "0.1" and so on)
47 $EXT_VER_HISTORY = array("0.0");
49 switch ($EXT_LOAD_MODE)
51 case "register": // Do stuff when installtion is running (modules.php?module=admin&action=login is called)
52 // SQL commands to run
53 $SQLs[] = "DROP TABLE IF EXISTS "._MYSQL_PREFIX."_bank_accounts";
54 $SQLs[] = "CREATE TABLE "._MYSQL_PREFIX."_bank_accounts (
55 id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
56 uid BIGINT(20) UNSIGNED NOT NULL DEFAULT '0',
57 account_created BIGINT(20) UNSIGNED NOT NULL DEFAULT '0',
58 account_locked BIGINT(20) UNSIGNED NOT NULL DEFAULT '0',
59 locked_reason TINYTEXT,
60 status ENUM('NEW','ACTIVE','LOCKED') NOT NULL DEFAULT 'NEW',
61 account_balance DOUBLE(20,5) UNSIGNED NOT NULL DEFAULT '0.00000',
62 output_mode ENUM('LOGIN','EMAIL','DISABLED'),
63 pin VARCHAR(50) NOT NULL DEFAULT '',
64 tan_mode ENUM('NORMAL','INDEXED'),
65 tan_list_status ENUM('PENDING','ACTIVE','INVALID','LOCKED') NOT NULL DEFAULT 'PENDING',
66 tan_key VARCHAR(50) NOT NULL DEFAULT '',
67 month_transfered BIGINT(20) UNSIGNED NOT NULL DEFAULT '0',
68 last_tan VARCHAR(5) NOT NULL DEFAULT '00000',
69 last_tan_stamp BIGINT(20) UNSIGNED NOT NULL DEFAULT '0',
70 last_tan_purpose TINYTEXT,
71 account_type ENUM('CHECK','SAVING') NOT NULL DEFAULT 'CHECK',
72 overdraft_credit DOUBLE(20,5) UNSIGNED NOT NULL DEFAULT '0.00000',
75 INDEX `uid_type` (uid, account_type),
76 INDEX (account_created),
77 INDEX (account_locked),
78 INDEX (last_tan_stamp)
80 $SQLs[] = "DROP TABLE IF EXISTS "._MYSQL_PREFIX."_bank_transfers";
81 $SQLs[] = "CREATE TABLE "._MYSQL_PREFIX."_bank_transfers (
82 id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
83 to_account_id BIGINT(20) UNSIGNED NOT NULL DEFAULT '0',
84 from_account_id BIGINT(20) UNSIGNED NOT NULL DEFAULT '0',
85 points_amount DOUBLE(20,5) UNSIGNED NOT NULL DEFAULT '0.00000',
86 day_bookkeeping CHAR(4) NOT NULL DEFAULT '0000',
87 day_available CHAR(4) NOT NULL DEFAULT '0000',
88 transfer_purpose TINYTEXT,
90 INDEX (to_account_id, from_account_id),
91 INDEX (day_bookkeeping, day_available)
93 $SQLs[] = "DROP TABLE IF EXISTS "._MYSQL_PREFIX."_bank_packages";
94 $SQLs[] = "CREATE TABLE "._MYSQL_PREFIX."_bank_packages (
95 id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
96 title VARCHAR(255) NOT NULL DEFAULT '',
98 account_fee DOUBLE(20,5) UNSIGNED NOT NULL DEFAULT '0.00000',
99 free_transfers INT(7) UNSIGNED NOT NULL DEFAULT '0',
100 transfer_fee DOUBLE(20,5) UNSIGNED NOT NULL DEFAULT '0.00000',
101 available TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
102 output_system_mode ENUM('LOGIN','EMAIL','DISABLED'),
103 package_active ENUM('Y','N') NOT NULL DEFAULT 'N',
104 free_months_no_fee TINYINT(3) UNSIGNED NOT NULL DEFAULT '0',
105 interest_plus FLOAT(7,5) UNSIGNED NOT NULL DEFAULT '0.00000',
106 interest_minus FLOAT(7,5) UNSIGNED NOT NULL DEFAULT '0.00000',
107 first_payment DOUBLE(20,5) UNSIGNED NOT NULL DEFAULT '0.00000',
108 free_account_income DOUBLE(20,5) UNSIGNED NOT NULL DEFAULT '0.00000',
109 free_account_stuff TINYTEXT null,
110 tan_lock TINYINT(3) UNSIGNED NOT NULL DEFAULT '0',
113 // free_account_stuff will be a list of columns of the table _bank_packages
114 // what the member shall get for the specified income. output_system_mode
115 // must be extended with the mode you get for free: output_system_mode:LOGIN
116 // should be fine. More than one entry and not DISABLED ;) are not supported.
117 $SQLs[] = "DROP TABLE IF EXISTS "._MYSQL_PREFIX."_bank_tanlist";
118 $SQLs[] = "CREATE TABLE "._MYSQL_PREFIX."_bank_tanlist (
119 id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
120 idx TINYINT(3) UNSIGNED NOT NULL DEFAULT '0',
121 account_id BIGINT(20) UNSIGNED NOT NULL DEFAULT '0',
122 tan VARCHAR(50) NOT NULL DEFAULT '',
123 used ENUM('Y','N') NOT NULL DEFAULT 'N',
125 UNIQUE (account_id, tan)
128 // Admin menu queries
129 $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_admin_menu (action, what, title, descr, sort) VALUES ('bank', NULL, 'Bank-Accounts','Verwalten Sie hier alle Bank-Accounts Ihrer Mitglieder, sowie Angebotspakete und Überweisungen.', 6)";
130 $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_admin_menu (action, what, title, descr, sort) VALUES ('bank','add_bank_package','Angebotspaket hinzufügen','Neues Angebotspaket erstellen.', 1)";
131 $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_admin_menu (action, what, title, descr, sort) VALUES ('bank','list_bank_package','Angebotspakete auflisten','Listet alle erstellten Angebotspakete auf.', 2)";
132 $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_admin_menu (action, what, title, descr, sort) VALUES ('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)";
133 $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_admin_menu (action, what, title, descr, sort) VALUES ('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)";
134 $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_admin_menu (action, what, title, descr, sort) VALUES ('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)";
135 $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_admin_menu (action, what, title, descr, sort) VALUES ('bank','add_bank_account','Konto anlegen','Legen Sie hier Konten für die Mitglieder an (falls Ihre Mitglieder nicht zurecht kommen).', 6)";
136 $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_admin_menu (action, what, title, descr, sort) VALUES ('bank','list_bank_account','Konten auflisten','Auflistung aller Konto oder eines ausw&auuml;hlbaren Mitglieds.', 7)";
137 $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_admin_menu (action, what, title, descr, sort) VALUES ('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)";
138 $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_admin_menu (action, what, title, descr, sort) VALUES ('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)";
139 $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_admin_menu (action, what, title, descr, sort) VALUES ('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)";
140 $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_admin_menu (action, what, title, descr, sort) VALUES ('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)";
141 $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_admin_menu (action, what, title, descr, sort) VALUES ('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)";
142 $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_admin_menu (action, what, title, descr, sort) VALUES ('bank','list_bank_trans','Überweisungen auflisten','Nach Auswahl eines Mitgliedes und einem Konto (benötgt JavaScript!) können Sie seitenweise die Überweisungen durchschauen.', 13)";
145 $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_member_menu (action, what, title, visible, locked, sort) VALUES ('bank', NULL, 'Bank-Account','N','Y', 3)";
146 $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_member_menu (action, what, title, visible, locked, sort) VALUES ('bank','bank_infos','Angebotspakete','N','Y', 1)";
147 $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_member_menu (action, what, title, visible, locked, sort) VALUES ('bank','bank_create','Konto anlegen','N','Y', 2)";
148 $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_member_menu (action, what, title, visible, locked, sort) VALUES ('bank','bank_deposit','Einzahlen','N','Y', 3)";
149 $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_member_menu (action, what, title, visible, locked, sort) VALUES ('bank','bank_withdraw','Auszahlen','N','Y', 4)";
150 $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_member_menu (action, what, title, visible, locked, sort) VALUES ('bank','bank_output','Kontoauszug','N','Y', 5)";
151 $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_member_menu (action, what, title, visible, locked, sort) VALUES ('bank','bank_change','Paket wechseln','N','Y', 6)";
152 $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_member_menu (action, what, title, visible, locked, sort) VALUES ('bank','bank_remove','Kündigen','N','Y', 7)";
155 case "remove": // Do stuff when removing extension
156 // SQL commands to run
157 $SQLs[] = "DROP TABLE IF EXISTS "._MYSQL_PREFIX."_bank_accounts";
158 $SQLs[] = "DROP TABLE IF EXISTS "._MYSQL_PREFIX."_bank_transfers";
159 $SQLs[] = "DROP TABLE IF EXISTS "._MYSQL_PREFIX."_bank_packages";
160 $SQLs[] = "DROP TABLE IF EXISTS "._MYSQL_PREFIX."_bank_tanlist";
161 $SQLs[] = "DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_admin_menu WHERE action='bank' LIMIT 14";
162 $SQLs[] = "DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_member_menu WHERE action='bank' LIMIT 8";
165 case "activate": // Do stuff when admin activates this extension
166 // SQL commands to run
167 $SQLs[] = "UPDATE "._MYSQL_PREFIX."_member_menu SET visible='Y', locked='N' WHERE action='bank' LIMIT 8";
170 case "deactivate": // Do stuff when admin deactivates this extension
171 // SQL commands to run
172 $SQLs[] = "UPDATE "._MYSQL_PREFIX."_member_menu SET visible='N', locked='Y' WHERE action='bank' LIMIT 8";
175 case "update": // Update an extension
178 case "0.0.1": // SQL queries for v0.0.1
181 // Update notes (these will be set as task text!)
187 default: // Do stuff when extension is loaded
191 // Language file prefix
192 $EXT_LANG_PREFIX = "bank";
194 // Extension is always active?
195 $EXT_ALWAYS_ACTIVE = "N";