6eed145160147927cb7c927632d3fa3be6055fb4
[mailer.git] / inc / extensions / ext-bank.php
1 <?php
2 /************************************************************************
3  * MXChange v0.2.1                                    Start: 05/28/2007 *
4  * ================                             Last change: 05/31/2007 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : ext-bank.php                                     *
8  * -------------------------------------------------------------------- *
9  * Short description : A little bank account                            *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Ein einfaches Bankaccount                        *
12  * -------------------------------------------------------------------- *
13  *                                                                      *
14  * -------------------------------------------------------------------- *
15  * Copyright (c) 2003 - 2008 by Roland Haeder                           *
16  * For more information visit: http://www.mxchange.org                  *
17  *                                                                      *
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.                                  *
22  *                                                                      *
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.                         *
27  *                                                                      *
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,               *
31  * MA  02110-1301  USA                                                  *
32  ************************************************************************/
33
34 // Some security stuff...
35 if ((ereg(basename(__FILE__), $_SERVER['PHP_SELF'])))
36 {
37         $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
38         require($INC);
39 }
40
41 // Version number
42 $EXT_VERSION = "0.0";
43
44 // Auto-set extension version
45 if (!isset($EXT_VER)) $EXT_VER = $EXT_VERSION;
46
47 // Version history array (add more with , "0.1" and so on)
48 $EXT_VER_HISTORY = array("0.0");
49
50 switch ($EXT_LOAD_MODE)
51 {
52 case "register": // Do stuff when installtion is running (modules.php?module=admin&action=login is called)
53         // SQL commands to run
54         $SQLs[] = "DROP TABLE IF EXISTS "._MYSQL_PREFIX."_bank_accounts";
55         $SQLs[] = "CREATE TABLE "._MYSQL_PREFIX."_bank_accounts (
56 id bigint(20) not null auto_increment,
57 uid bigint(20) not null default '0',
58 account_created bigint(20) not null default '0',
59 account_locked bigint(20) not null default '0',
60 locked_reason tinytext,
61 status enum('NEW', 'ACTIVE', 'LOCKED') not null default 'NEW',
62 account_balance double(20,5) not null default '0.00000',
63 output_mode enum('LOGIN', 'EMAIL', 'DISABLED'),
64 pin varchar(50) not null default '',
65 tan_mode enum('NORMAL', 'INDEXED'),
66 tan_list_status enum('PENDING', 'ACTIVE', 'INVALID', 'LOCKED') not null default 'PENDING',
67 tan_key varchar(50) not null default '',
68 month_transfered bigint(20) not null default '0',
69 last_tan varchar(5) not null default '00000',
70 last_tan_stamp bigint(20) not null default '0',
71 last_tan_purpose tinytext,
72 account_type enum('CHECK', 'SAVING') not null default 'CHECK',
73 overdraft_credit double(20,5) not null default '0.00000',
74 PRIMARY KEY (id),
75 UNIQUE KEY (pin),
76 INDEX `uid_type` (uid, account_type),
77 INDEX (account_created),
78 INDEX (account_locked),
79 INDEX (last_tan_stamp)
80 ) TYPE=MyISAM";
81         $SQLs[] = "DROP TABLE IF EXISTS "._MYSQL_PREFIX."_bank_transfers";
82         $SQLs[] = "CREATE TABLE "._MYSQL_PREFIX."_bank_transfers (
83 id bigint(20) not null auto_increment,
84 to_account_id bigint(20) not null default '0',
85 from_account_id bigint(20) not null default '0',
86 points_amount double(20,5) not null default '0.00000',
87 day_bookkeeping char(4) not null default '0000',
88 day_available char(4) not null default '0000',
89 transfer_purpose tinytext,
90 PRIMARY KEY (id),
91 INDEX (to_account_id, from_account_id),
92 INDEX (day_bookkeeping, day_available)
93 ) TYPE=MyISAM";
94         $SQLs[] = "DROP TABLE IF EXISTS "._MYSQL_PREFIX."_bank_packages";
95         $SQLs[] = "CREATE TABLE "._MYSQL_PREFIX."_bank_packages (
96 id bigint(20) not null auto_increment,
97 title varchar(255) not null default '',
98 description tinytext,
99 account_fee double(20,5) not null default '0.00000',
100 free_transfers int(7) not null default '0',
101 transfer_fee double(20,5) not null default '0.00000',
102 available varchar(8) not null default '19700101',
103 output_system_mode enum('LOGIN', 'EMAIL', 'DISABLED'),
104 package_active enum('Y', 'N') not null default 'N',
105 free_months_no_fee tinyint(3) not null default '0',
106 interest_plus float(7,5) not null default '0.00000',
107 interest_minus float(7,5) not null default '0.00000',
108 first_payment double(20,5) not null default '0.00000',
109 free_account_income double(20,5) not null default '0.00000',
110 free_account_stuff tinytext null,
111 tan_lock tinyint(3) not null default '0',
112 PRIMARY KEY (id)
113 ) TYPE=MyISAM";
114         // free_account_stuff will be a list of columns of the table _bank_packages
115         // what the member shall get for the specified income. output_system_mode
116         // must be extended with the mode you get for free: output_system_mode:LOGIN
117         // should be fine. More than one entry and not DISABLED ;) are not supported.
118         $SQLs[] = "DROP TABLE IF EXISTS "._MYSQL_PREFIX."_bank_tanlist";
119         $SQLs[] = "CREATE TABLE "._MYSQL_PREFIX."_bank_tanlist (
120 id bigint(20) not null auto_increment,
121 idx tinyint(3) not null default '0',
122 account_id bigint(20) not null default '0',
123 tan varchar(50) not null default '',
124 used enum('Y', 'N') not null default 'N',
125 PRIMARY KEY (id),
126 UNIQUE (account_id, tan)
127 ) TYPE=MyISAM";
128
129         // Admin menu queries
130         $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 &Uuml;berweisungen.', 6)";
131         $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_admin_menu (action, what, title, descr, sort) VALUES ('bank', 'add_bank_package', 'Angebotspaket hinzuf&uuml;gen', 'Neues Angebotspaket erstellen.', 1)";
132         $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)";
133         $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_admin_menu (action, what, title, descr, sort) VALUES ('bank', 'edit_bank_package', 'Angebotspaket &auml;ndern', 'Nach Auswahl eines Angebotspaketes k&ouml;nnen Sie dieses hier ver&auml;ndern. Bitte beachten Sie, dass Ihre Mitglieder keine Mail dabei erhalten!', 3)";
134         $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&auml;ren &Uuml;berarbeitung zuvor heraus, dann k&ouml;nnen Sie in Ruhe dr&uuml;ber nachdenken und Berechnungen anstellen. Freigabe ist hier auch m&ouml;glich.', 4)";
135         $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_admin_menu (action, what, title, descr, sort) VALUES ('bank', 'del_bank_package', 'Angebotspaket l&ouml;schen', 'Nach Auswahl eines Angebotspaketes k&ouml;nnen Sie mit abschliessender Best&auml;tigung Angebotspakete ganz l&ouml;schen. Bitte beachten Sie, dass dies nur m&ouml;glich ist, wenn auch alle Accounts dieses nicht mehr nutzen!', 5)";
136         $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_admin_menu (action, what, title, descr, sort) VALUES ('bank', 'add_bank_account', 'Konto anlegen', 'Legen Sie hier Konten f&uuml;r die Mitglieder an (falls Ihre Mitglieder nicht zurecht kommen).', 6)";
137         $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)";
138         $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_admin_menu (action, what, title, descr, sort) VALUES ('bank', 'edit_bank_account', 'Konto &auml;ndern', '&Auml;ndern Sie hier bestehende Konten, z.B. den Dispositionskredit usw. PINs und TANs sind hier nicht &auml;nderbar! Best&auml;tigungsmails sind optional versendbar.', 8)";
139         $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&ouml;glich. Eine Benachrichtigung per Mail wird dann an das Mitglied ausgesendet.', 9)";
140         $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_admin_menu (action, what, title, descr, sort) VALUES ('bank', 'del_bank_account', 'Konto l&ouml;schen', 'L&ouml;schen von Konten mit Best&auml;tigungsmail. Wenn Sie ein Mitglieder-Account l&ouml;schen, so m&uuml;ssen Sie derzeit seine angelegten Konten auch l&ouml;schen!', 10)";
141         $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&ouml;tigen, anschliessend kann die Liste dann ausgesendet werden.', 11)";
142         $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&ouml;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)";
143         $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_admin_menu (action, what, title, descr, sort) VALUES ('bank', 'list_bank_trans', '&Uuml;berweisungen auflisten', 'Nach Auswahl eines Mitgliedes und einem Konto (ben&ouml;tgt JavaScript!) k&ouml;nnen Sie seitenweise die &Uuml;berweisungen durchschauen.', 13)";
144
145         // Member menu
146         $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_member_menu (action, what, title, visible, locked, sort) VALUES ('bank', NULL, 'Bank-Account', 'N', 'Y', 3)";
147         $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_member_menu (action, what, title, visible, locked, sort) VALUES ('bank', 'bank_infos', 'Angebotspakete', 'N', 'Y', 1)";
148         $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_member_menu (action, what, title, visible, locked, sort) VALUES ('bank', 'bank_create', 'Konto anlegen', 'N', 'Y', 2)";
149         $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_member_menu (action, what, title, visible, locked, sort) VALUES ('bank', 'bank_deposit', 'Einzahlen', 'N', 'Y', 3)";
150         $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_member_menu (action, what, title, visible, locked, sort) VALUES ('bank', 'bank_withdraw', 'Auszahlen', 'N', 'Y', 4)";
151         $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_member_menu (action, what, title, visible, locked, sort) VALUES ('bank', 'bank_output', 'Kontoauszug', 'N', 'Y', 5)";
152         $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_member_menu (action, what, title, visible, locked, sort) VALUES ('bank', 'bank_change', 'Paket wechseln', 'N', 'Y', 6)";
153         $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_member_menu (action, what, title, visible, locked, sort) VALUES ('bank', 'bank_remove', 'K&uuml;ndigen', 'N', 'Y', 7)";
154         break;
155
156 case "remove": // Do stuff when removing extension
157         // SQL commands to run
158         $SQLs[] = "DROP TABLE IF EXISTS "._MYSQL_PREFIX."_bank_accounts";
159         $SQLs[] = "DROP TABLE IF EXISTS "._MYSQL_PREFIX."_bank_transfers";
160         $SQLs[] = "DROP TABLE IF EXISTS "._MYSQL_PREFIX."_bank_packages";
161         $SQLs[] = "DROP TABLE IF EXISTS "._MYSQL_PREFIX."_bank_tanlist";
162         $SQLs[] = "DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_admin_menu WHERE action='bank' LIMIT 14";
163         $SQLs[] = "DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_member_menu WHERE action='bank' LIMIT 8";
164         break;
165
166 case "activate": // Do stuff when admin activates this extension
167         // SQL commands to run
168         $SQLs[] = "UPDATE "._MYSQL_PREFIX."_member_menu SET visible='Y', locked='N' WHERE action='bank' LIMIT 8";
169         break;
170
171 case "deactivate": // Do stuff when admin deactivates this extension
172         // SQL commands to run
173         $SQLs[] = "UPDATE "._MYSQL_PREFIX."_member_menu SET visible='N', locked='Y' WHERE action='bank' LIMIT 8";
174         break;
175
176 case "update": // Update an extension
177         switch ($EXT_VER)
178         {
179         case "0.0.1": // SQL queries for v0.0.1
180                 $SQLs[] = "";
181
182                 // Update notes (these will be set as task text!)
183                 $UPDATE_NOTES = "";
184                 break;
185         }
186         break;
187
188 default: // Do stuff when extension is loaded
189         break;
190 }
191
192 // Language file prefix
193 $EXT_LANG_PREFIX = "bank";
194
195 // Extension is always active?
196 $EXT_ALWAYS_ACTIVE = 'N';
197
198 //
199 ?>