/
time_import_6.php
112 lines (104 loc) · 3.74 KB
/
time_import_6.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<?
/**
*
* 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');
$title = 'Import Time - Preview Import';
$importer = new SI_TimeImport();
if(isset($_SESSION['SureInvoice']['TimeImport'])){
$importer =& $_SESSION['SureInvoice']['TimeImport'];
}else{
fatal_error("Import is not in progress!");
}
$headers = $importer->getColumnHeaders();
if(isset($_POST['restart'])){
unset($_SESSION['SureInvoice']['TimeImport']);
header("Location: ".getCurrentURL('time_import_1.php'));
exit();
}
if(isset($_POST['back'])){
header("Location: ".getCurrentURL('time_import_4.php'));
exit();
}
if(isset($_POST['save'])){
header("Location: ".getCurrentURL('time_import_7.php'));
exit();
}
if($_POST['preview']){
$results = $importer->run();
}
//var_dump($importer);
$task = new SI_Task();
$user = new SI_User();
$ic = new SI_ItemCode();
?>
<? 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="time_import" action="<?= $_SERVER['PHP_SELF'] ?>" METHOD="POST" ENCTYPE="multipart/form-data">
<table border="0" cellspacing="5" cellpadding="0" class="form_table">
<tr>
<td>
<p>Now we are going to run a test of the import. Please press the Preview button below to start. The results will be displayed below.</p>
</td>
</tr>
<tr><td>
<? if(isset($_POST['preview'])){ ?>
<div class="tableContainer">
<a href="javascript:;" class="tCollapse" onclick="toggleGrid(this)"><img src="images/arrow_down.jpg" alt="Hide table" />Results</a><div>
<table border="0" cellspacing="" cellpadding="0" class="dg_table">
<tr id="tasklist_header">
<th>Action</th>
<th>Project & Task</th>
<th>Item Code</th>
<th>Time</th>
<th>User</th>
<th>Message</th>
</tr>
<? foreach($results as $result){ ?>
<tr>
<td><?= $result['action'] == 'Skip' ? "<span style='color: red'>Skip</span>" : "<span style='color: green'>Import</span>"?></td>
<td><?= $task->getLongName($result['task_id']) ?></td>
<td><?= $ic->getCodeName($result['item_code_id']) ?></td>
<td><?= date('Y-m-d H:i', $result['start_ts']).' - '.date('H:i',$result['end_ts'])?></td>
<td><?= $user->getUserName($result['user_id']) ?></td>
<td><?= $result['message'] ?></td>
</tr>
<? } ?>
</table>
</div></div>
<? } ?>
</td></tr>
<tr>
<td>
<input type="submit" name="restart" class="button" value="Restart" />
<input type="submit" name="back" class="button" value="« Back" />
<input type="submit" name="preview" class="button" value="Run Preview" />
<input type="submit" name="save" class="button" value="Next »" />
</td>
</tr>
</table>
</form>
</div><div class="boxBottom"><span class="boxCornerL"> </span><span class="boxCornerR"></span></div>
</div>
<? require('footer.php'); ?>