-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.php
83 lines (76 loc) · 3.44 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<?php
/**
* phpDTAUS helps you creating so-called DTAUS (Datenaustauschverfahren) files. This file format
* was devised by the German ZKA or Zentraler Kreditausschuss (Central Credit Committee) in the
* mid-seventies. It is used for the automated processing of wire transfers and direct debits in
* Germany. The files created with this class are either sent to the bank (via email or any other
* means) or imported into online banking software for processing.
*
* To check the validity of the file you may visit http://www.xpecto.de/content/dtauschecker. There
* you simply upload the created file. If everything is alright, you should get a message that the
* file is valid, as well as a list of the transactions that were encoded in the file.
*
* @author Alexander Serbe <[email protected]>
* @version 1.0
* @copyright Copyright 2012 by progressive design and technology
* @license http://www.gnu.org/licenses/lgpl-3.0.txt GNU Lesser General Public License
*
* ------------------------------------------------------------------------------------------------
*
* phpDTAUS 1.0
* Copyright (c) 2010 by progressive design and technology
*
* This program is free software: you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
* You should have received a copy of the GNU Lesser General Public License along with this
* program. If not, see <http://www.gnu.org/licenses/>.
*/
// Include the phpDTAUS class
require_once 'phpDTAUS.php';
// Set some values we will need to create either the object or later the DTAUS file
$originator_name = 'Mustermann AG';
$originator_bankcode = 10000000;
$originator_account = 123456789;
$type = 'L';
$typeDetailed = '05';
// Create the phpDTAUS object
$dtaus = new phpDTAUS($originator_name, $originator_bankcode, $originator_account, $type);
// This mapping shows the readCsv method where (which column) to look for the required information in the CSV file
$mapping = array(
'name' => 2,
'bankCode' => 3,
'account' => 4,
'amount' => 5,
'ref' => 6,
'customerId' => 1
);
// First, we try to read the CSV file. The readCsv method accepts three parameters:
// * the name of the CSV file (including path information),
// * the mapping of the CSV values, and
// * the default reference to be used for the transactions.
try {
$dtaus->readCsv('test.csv', $mapping, 'Produkt XY');
} catch (Exception $e) {
echo 'Error reading CSV file: ' . $e->getMessage();
echo PHP_EOL . PHP_EOL;
echo $e->getTraceAsString();
}
// If a GET parameter 'file' is present and has the value '1', we will output the DTAUS file as plain text and make
// it downloadable. Otherwise we just print the DTAUS contents to the screen.
if( !empty($_GET['file']) && $_GET['file'] == '1' ) {
header('Content-Disposition:attachment; filename=dtaus0.txt');
header('Content-type:text/plain' );
header('Cache-control:public' );
}
try {
print $dtaus->createDtaus($type, '784535', '');
} catch (Exception $e) {
echo 'Error creating DTAUS file: ' . $e->getMessage();
echo PHP_EOL . PHP_EOL;
echo $e->getTraceAsString();
}
?>