forked from ATM-Consulting/dolibarr_module_bankimport
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimport.php
84 lines (63 loc) · 2.79 KB
/
import.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
84
<?php
/* <one line to give the program's name and a brief idea of what it does.>
* Copyright (C) 2013 ATM Consulting <[email protected]>
*
* 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 General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// Permet de gérer les fichier ayant une fin de ligne MAC (suite retour client) (http://stackoverflow.com/questions/4541749/fgetcsv-fails-to-read-line-ending-in-mac-formatted-csv-file-any-better-solution)
require 'config.php';
dol_include_once('/bankimport/class/bankimport.class.php');
dol_include_once('/compta/facture/class/facture.class.php');
global $db, $langs;
$langs->load('bills');
ini_set("auto_detect_line_endings", true);
$mesg = "";
$form = new Form($db);
$tpl = 'tpl/bankimport.new.tpl.php';
$import = new BankImport($db);
if(GETPOST('compare','alphanohtml')) {
$datestart = dol_mktime(0, 0, 0, GETPOST('dsmonth','int'), GETPOST('dsday','int'), GETPOST('dsyear','int'));
$dateend = dol_mktime(0, 0, 0, GETPOST('demonth','int'), GETPOST('deday','int'), GETPOST('deyear','int'));
$numreleve = GETPOST('numreleve','alphanohtml');
$hasHeader = GETPOST('hasheader','alphanohtml');
if($import->analyse(GETPOST('accountid','int'), 'bankimportfile', $datestart, $dateend, $numreleve, $hasHeader)) {
$import->load_transactions(GETPOST('bankimportseparator','alphanohtml'), GETPOST('bankimportdateformat','alphanohtml'), GETPOST('bankimportmapping','alphanohtml'));
$import->compare_transactions();
$TTransactions = $import->TFile;
global $bc;
$langs->load('bankimport@bankimport');
$var = true;
$tpl = 'tpl/bankimport.check.tpl.php';
}
} else if(GETPOST('import','alphanohtml')) {
if(
$import->analyse(
GETPOST('accountid','int'),
GETPOST('filename','alpha'),
GETPOST('datestart','int'),
GETPOST('dateend','int'),
GETPOST('numreleve','alphanohtml'),
GETPOST('hasheader','alphanohtml')
)
) {
$import->load_transactions(GETPOST('bankimportseparator','alpha'), GETPOST('bankimportdateformat','alphanohtml'), GETPOST('bankimportmapping','alphanohtml'));
$import->import_data(GETPOST('TLine','array'));
$tpl = 'tpl/bankimport.end.tpl.php';
}
}
llxHeader('', $langs->trans('TitleBankImport'));
print_fiche_titre($langs->trans("TitleBankImport"));
include($tpl);
llxFooter();
$db->close();