/
qb_import.php
85 lines (78 loc) · 2.83 KB
/
qb_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
85
<?
/**
*
* Copyright (C) 2003-2011 Cory Powers
*
* 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 2 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, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
require_once('includes/common.php');
checkLogin();
require_once('includes/SI_Company.php');
require_once('includes/SI_ItemCode.php');
require_once('includes/SI_Account.php');
require_once('includes/QBExporter/QBImporter.php');
$title = 'Import From Quickbooks';
if($_POST['save']){
$importer = new QBImporter();
$dest_file = '/tmp/'.basename($_FILES['iif_file']['name']);
if(!move_uploaded_file($_FILES['iif_file']['tmp_name'], $dest_file)){
$error_msg .= "Could not move uploaded file!";
}else{
$data = $importer->import($dest_file);
if($data === FALSE){
$error_msg .= "Error importing file!";
debug_message($importer->getLastError());
}
$company = new SI_Company();
if($company->importQB($data) === FALSE){
$error_msg .= "Error importing company data!";
debug_message($company->getLastError());
}
$code = new SI_ItemCode();
if($code->importQB($data) === FALSE){
$error_msg .= "Error importing item code data!";
debug_message($code->getLastError());
}
$account = new SI_Account();
if($account->importQB($data) === FALSE){
$error_msg .= "Error importing account data!";
debug_message($account->getLastError());
}
}
}
?>
<? require('header.php'); ?>
<div class="box">
<div class="boxTitle"><h3><?= $title ?></h3><span class="boxTitleRight"> </span><span class="boxTitleCorner"> </span></div><div class="boxContent">
<form name="qb_import" action="<?= $_SERVER['PHP_SELF'] ?>" METHOD="POST" ENCTYPE="multipart/form-data">
<table border="0" cellspacing="5" cellpadding="0" class="form_table">
<tr>
<td><label for="iif_file">File</label></td>
<td><input name="iif_file" type="file" id="iif_file"/></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="save" class="button" value="Import »" /></td>
</tr>
</table>
</form>
<p>
<? if($data){var_dump($data);} ?>
</p>
</div><div class="boxBottom"><span class="boxCornerL"> </span><span class="boxCornerR"></span></div>
</div>
<? require('footer.php'); ?>