Old config.php is now automatically updated to new config-local.php format, several...
[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  * $Revision::                                                        $ *
14  * $Date::                                                            $ *
15  * $Tag:: 0.2.1-FINAL                                                 $ *
16  * $Author::                                                          $ *
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 - 2008 by Roland Haeder                           *
21  * For more information visit: http://www.mxchange.org                  *
22  *                                                                      *
23  * This program is free software; you can redistribute it and/or modify *
24  * it under the terms of the GNU General Public License as published by *
25  * the Free Software Foundation; either version 2 of the License, or    *
26  * (at your option) any later version.                                  *
27  *                                                                      *
28  * This program is distributed in the hope that it will be useful,      *
29  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
30  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
31  * GNU General Public License for more details.                         *
32  *                                                                      *
33  * You should have received a copy of the GNU General Public License    *
34  * along with this program; if not, write to the Free Software          *
35  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
36  * MA  02110-1301  USA                                                  *
37  ************************************************************************/
38
39 // Some security stuff...
40 if (!defined('__SECURITY')) {
41         $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), '/inc') + 4) . '/security.php';
42         require($INC);
43 }
44
45 // Version number
46 EXT_SET_VERSION('0.0');
47
48 // Version history array (add more with , '0.1.0' and so on)
49 EXT_SET_VER_HISTORY(array('0.0'));
50
51 switch ($EXT_LOAD_MODE)
52 {
53         case 'register': // Do stuff when installation is running (modules.php?module=admin&action=login is called)
54                 // SQL commands to run
55                 ADD_EXT_SQL("DROP TABLE IF EXISTS `{!_MYSQL_PREFIX!}_bank_accounts`");
56                 ADD_EXT_SQL("CREATE TABLE `{!_MYSQL_PREFIX!}_bank_accounts` (
57 id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
58 uid BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
59 account_created BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
60 account_locked BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
61 locked_reason TINYTEXT,
62 status ENUM('NEW','ACTIVE','LOCKED') NOT NULL DEFAULT 'NEW',
63 account_balance FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000,
64 output_mode ENUM('LOGIN','EMAIL','DISABLED'),
65 pin VARCHAR(50) NOT NULL DEFAULT '',
66 tan_mode ENUM('NORMAL','INDEXED'),
67 tan_list_status ENUM('PENDING','ACTIVE','INVALID','LOCKED') NOT NULL DEFAULT 'PENDING',
68 tan_key VARCHAR(50) NOT NULL DEFAULT '',
69 month_transfered BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
70 last_tan VARCHAR(5) NOT NULL DEFAULT '00000',
71 last_tan_stamp BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
72 last_tan_purpose TINYTEXT,
73 account_type ENUM('CHECK','SAVING') NOT NULL DEFAULT 'CHECK',
74 overdraft_credit FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000,
75 PRIMARY KEY (id),
76 UNIQUE KEY (pin),
77 INDEX `uid_type` (uid, account_type),
78 INDEX (account_created),
79 INDEX (account_locked),
80 INDEX (last_tan_stamp)
81 ) TYPE={!_TABLE_TYPE!}");
82                 ADD_EXT_SQL("DROP TABLE IF EXISTS `{!_MYSQL_PREFIX!}_bank_transfers`");
83                 ADD_EXT_SQL("CREATE TABLE `{!_MYSQL_PREFIX!}_bank_transfers` (
84 id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
85 to_account_id BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
86 from_account_id BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
87 points_amount FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000,
88 day_bookkeeping CHAR(4) NOT NULL DEFAULT '0000',
89 day_available CHAR(4) NOT NULL DEFAULT '0000',
90 transfer_purpose TINYTEXT,
91 PRIMARY KEY (id),
92 INDEX (to_account_id, from_account_id),
93 INDEX (day_bookkeeping, day_available)
94 ) TYPE={!_TABLE_TYPE!}");
95                 ADD_EXT_SQL("DROP TABLE IF EXISTS `{!_MYSQL_PREFIX!}_bank_packages`");
96                 ADD_EXT_SQL("CREATE TABLE `{!_MYSQL_PREFIX!}_bank_packages` (
97 id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
98 title VARCHAR(255) NOT NULL DEFAULT '',
99 description TINYTEXT,
100 account_fee FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000,
101 free_transfers INT(7) UNSIGNED NOT NULL DEFAULT 0,
102 transfer_fee FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000,
103 available TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
104 output_system_mode ENUM('LOGIN','EMAIL','DISABLED'),
105 package_active ENUM('Y','N') NOT NULL DEFAULT 'N',
106 free_months_no_fee TINYINT(3) UNSIGNED NOT NULL DEFAULT 0,
107 interest_plus FLOAT(7,5) UNSIGNED NOT NULL DEFAULT 0.00000,
108 interest_minus FLOAT(7,5) UNSIGNED NOT NULL DEFAULT 0.00000,
109 first_payment FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000,
110 free_account_income FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000,
111 free_account_stuff TINYTEXT null,
112 tan_lock TINYINT(3) UNSIGNED NOT NULL DEFAULT 0,
113 PRIMARY KEY (id)
114 ) TYPE={!_TABLE_TYPE!}");
115                 // free_account_stuff will be a list of columns of the table _bank_packages
116                 // what the member shall get for the specified income. output_system_mode
117                 // must be extended with the mode you get for free: output_system_mode:LOGIN
118                 // should be fine. More than one entry and not DISABLED ;) are not supported.
119                 ADD_EXT_SQL("DROP TABLE IF EXISTS `{!_MYSQL_PREFIX!}_bank_tanlist`");
120                 ADD_EXT_SQL("CREATE TABLE `{!_MYSQL_PREFIX!}_bank_tanlist` (
121 id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
122 idx TINYINT(3) UNSIGNED NOT NULL DEFAULT 0,
123 account_id BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
124 tan VARCHAR(50) NOT NULL DEFAULT '',
125 used ENUM('Y','N') NOT NULL DEFAULT 'N',
126 PRIMARY KEY (id),
127 UNIQUE (account_id, tan)
128 ) TYPE={!_TABLE_TYPE!}");
129
130                 // Admin menu queries
131                 ADD_EXT_SQL("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)");
132                 ADD_EXT_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_admin_menu` (`action`,`what`,`title`,`descr`,`sort`) VALUES ('bank','add_bank_package','Angebotspaket hinzuf&uuml;gen','Neues Angebotspaket erstellen.', 1)");
133                 ADD_EXT_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_admin_menu` (`action`,`what`,`title`,`descr`,`sort`) VALUES ('bank','list_bank_package','Angebotspakete auflisten','Listet alle erstellten Angebotspakete auf.', 2)");
134                 ADD_EXT_SQL("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)");
135                 ADD_EXT_SQL("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)");
136                 ADD_EXT_SQL("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)");
137                 ADD_EXT_SQL("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)");
138                 ADD_EXT_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_admin_menu` (`action`,`what`,`title`,`descr`,`sort`) VALUES ('bank','list_bank_account','Konten auflisten','Auflistung aller Konto oder eines ausw&auml;hlbaren Mitglieds.', 7)");
139                 ADD_EXT_SQL("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)");
140                 ADD_EXT_SQL("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)");
141                 ADD_EXT_SQL("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)");
142                 ADD_EXT_SQL("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)");
143                 ADD_EXT_SQL("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)");
144                 ADD_EXT_SQL("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)");
145
146                 // Member menu
147                 ADD_EXT_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_member_menu` (`action`,`what`,`title`,`visible`,`locked`,`sort`) VALUES ('bank', NULL, 'Bank-Account','N','Y', 3)");
148                 ADD_EXT_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_member_menu` (`action`,`what`,`title`,`visible`,`locked`,`sort`) VALUES ('bank','bank_infos','Angebotspakete','N','Y', 1)");
149                 ADD_EXT_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_member_menu` (`action`,`what`,`title`,`visible`,`locked`,`sort`) VALUES ('bank','bank_create','Konto anlegen','N','Y', 2)");
150                 ADD_EXT_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_member_menu` (`action`,`what`,`title`,`visible`,`locked`,`sort`) VALUES ('bank','bank_deposit','Auf Konto einzahlen','N','Y', 3)");
151                 ADD_EXT_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_member_menu` (`action`,`what`,`title`,`visible`,`locked`,`sort`) VALUES ('bank','bank_withdraw','Vom Konto abheben','N','Y', 4)");
152                 ADD_EXT_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_member_menu` (`action`,`what`,`title`,`visible`,`locked`,`sort`) VALUES ('bank','bank_output','Kontoauszug','N','Y', 5)");
153                 ADD_EXT_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_member_menu` (`action`,`what`,`title`,`visible`,`locked`,`sort`) VALUES ('bank','bank_change','Paket wechseln','N','Y', 6)");
154                 ADD_EXT_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_member_menu` (`action`,`what`,`title`,`visible`,`locked`,`sort`) VALUES ('bank','bank_remove','Konto K&uuml;ndigen','N','Y', 7)");
155                 break;
156
157         case 'remove': // Do stuff when removing extension
158                 // SQL commands to run
159                 ADD_EXT_SQL("DROP TABLE IF EXISTS `{!_MYSQL_PREFIX!}_bank_accounts`");
160                 ADD_EXT_SQL("DROP TABLE IF EXISTS `{!_MYSQL_PREFIX!}_bank_transfers`");
161                 ADD_EXT_SQL("DROP TABLE IF EXISTS `{!_MYSQL_PREFIX!}_bank_packages`");
162                 ADD_EXT_SQL("DROP TABLE IF EXISTS `{!_MYSQL_PREFIX!}_bank_tanlist`");
163                 ADD_EXT_SQL("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_admin_menu` WHERE `action`='bank'");
164                 ADD_EXT_SQL("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_member_menu` WHERE `action`='bank'");
165                 break;
166
167         case 'activate': // Do stuff when admin activates this extension
168                 // SQL commands to run
169                 ADD_EXT_SQL("UPDATE `{!_MYSQL_PREFIX!}_member_menu` SET `visible`='Y', `locked`='N' WHERE `action`='bank' LIMIT 8");
170                 break;
171
172         case 'deactivate': // Do stuff when admin deactivates this extension
173                 // SQL commands to run
174                 ADD_EXT_SQL("UPDATE `{!_MYSQL_PREFIX!}_member_menu` SET `visible`='N', `locked`='Y' WHERE `action`='bank' LIMIT 8");
175                 break;
176
177         case 'update': // Update an extension
178                 switch ($EXT_VER)
179                 {
180                         case '0.0.1': // SQL queries for v0.0.1
181                                 ADD_EXT_SQL('');
182
183                                 // Update notes (these will be set as task text!)
184                                 EXT_SET_UPDATE_NOTES('');
185                                 break;
186                 }
187                 break;
188
189                         case 'modify': // When the extension got modified
190                                 break;
191
192                         case 'test': // For testing purposes. For details see file inc/modules/admin/what-extensions.php, arround line 305.
193                                 break;
194
195                         default: // Do stuff when extension is loaded
196                                 break;
197 }
198
199 //
200 ?>