109 lines
3.5 KiB
PHP
109 lines
3.5 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
require_once("TogglConverter.inc");
|
||
|
|
require_once("ToggleVerifier.inc");
|
||
|
|
|
||
|
|
$folderKey = '';
|
||
|
|
|
||
|
|
header('Content-type: text/html; charset=UTF-8');
|
||
|
|
|
||
|
|
if (!isset($_FILES['file']) || !isset($_FILES['file']['tmp_name']) || $_FILES['file']['tmp_name'] == '') {
|
||
|
|
?>
|
||
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||
|
|
"http://www.w3.org/TR/html4/loose.dtd">
|
||
|
|
<html>
|
||
|
|
<head>
|
||
|
|
<title>Rebased CSV Import Tool</title>
|
||
|
|
</head>
|
||
|
|
<body>
|
||
|
|
|
||
|
|
<form action="index.php" method="post" enctype="multipart/form-data">
|
||
|
|
Rebased Toggl CSV File to Import: <br>
|
||
|
|
<input type="file" id="file" name="file"><br>
|
||
|
|
<br>
|
||
|
|
<input type="hidden" name="method" value="import">
|
||
|
|
<input type="submit" value="Process File">
|
||
|
|
</form>
|
||
|
|
|
||
|
|
<br><br>
|
||
|
|
|
||
|
|
<table border="1" cellpadding="5" cellspacing="0">
|
||
|
|
<?
|
||
|
|
foreach (ToggleVerifier::getFolderKeys() as $folderKey) {
|
||
|
|
echo("<tr><td>$folderKey</td><td>" . (ToggleVerifier::isFolderVerified($folderKey) ? '<span style="color: DarkGreen">Verified</span>' : '<span style="color: DarkRed">Not Verified</span>') . "</td>");
|
||
|
|
}
|
||
|
|
?>
|
||
|
|
</table>
|
||
|
|
|
||
|
|
</body>
|
||
|
|
</html>
|
||
|
|
<?
|
||
|
|
exit;
|
||
|
|
}
|
||
|
|
|
||
|
|
$filename = $_FILES['file']['tmp_name'];
|
||
|
|
|
||
|
|
if ($_POST['method'] == 'import') {
|
||
|
|
$toggl = new TogglConverter();
|
||
|
|
if (!$toggl->parseFile($filename)) {
|
||
|
|
echo($toggl->getLastError());
|
||
|
|
exit;
|
||
|
|
}
|
||
|
|
|
||
|
|
echo("Users found: " . implode(', ', $toggl->getUsers()) . "<br>");
|
||
|
|
echo("Rows parsed: " . $toggl->getNumEntries() . "<br>");
|
||
|
|
echo("Total time: " . $toggl->getTotalTime() . "<br>");
|
||
|
|
foreach ($toggl->getWorkspace('Unknown') as $row) {
|
||
|
|
echo("Unknown entry: " . $row->description . "<br>");
|
||
|
|
}
|
||
|
|
|
||
|
|
$links = $toggl->saveImportCsv();
|
||
|
|
foreach ($links as $link) {
|
||
|
|
echo("<a href=\"$link\">$link</a><br>");
|
||
|
|
}
|
||
|
|
|
||
|
|
$folderKey = $toggl->getFolderKey();
|
||
|
|
} else if ($_POST['method'] == 'verify') {
|
||
|
|
$workspace = $_POST['workspace'];
|
||
|
|
$folderKey = $_POST['folderKey'];
|
||
|
|
$toggl = new ToggleVerifier($workspace, $folderKey);
|
||
|
|
if (!$toggl->parseFile($filename)) {
|
||
|
|
echo($toggl->getLastError() . '<br><br>');
|
||
|
|
} else if (!$toggl->verify()) {
|
||
|
|
echo($toggl->getLastError() . '<br><br>');
|
||
|
|
}
|
||
|
|
|
||
|
|
echo('<table border="1" cellpadding="5" cellspacing="0">');
|
||
|
|
foreach (ToggleVerifier::getVerifiedStatus($folderKey) as $ws => $status) {
|
||
|
|
echo('<tr><td>' . $ws . '</td><td>' . ($status ? '<span style="color: DarkGreen">Verified</span>' : '<span style="color: DarkRed">Not Verified</span>') . '</td></tr>');
|
||
|
|
}
|
||
|
|
echo('</table>');
|
||
|
|
}
|
||
|
|
|
||
|
|
?>
|
||
|
|
|
||
|
|
<br><br>
|
||
|
|
|
||
|
|
<form action="index.php" method="post" enctype="multipart/form-data">
|
||
|
|
<label for="file">Analytics Fire Toggl CSV File to Verify Against:</label><br>
|
||
|
|
<input type="file" id="file" name="file"><br>
|
||
|
|
<br>
|
||
|
|
<label for="workspace">Workspace to Verify:</label><br>
|
||
|
|
<select name="workspace">
|
||
|
|
<option value="Arthrex">Arthrex</option>
|
||
|
|
<option value="SunPower">SunPower</option>
|
||
|
|
<option value="iCracked">iCracked</option>
|
||
|
|
<option value="Aeolus">Aeolus</option>
|
||
|
|
<option value="Analytics Fire">Analytics Fire</option>
|
||
|
|
</select>
|
||
|
|
<br><br>
|
||
|
|
<input type="hidden" name="method" value="verify">
|
||
|
|
<input type="hidden" name="folderKey" value="<?= $folderKey ?>">
|
||
|
|
<input type="submit" value="Verify File">
|
||
|
|
</form>
|
||
|
|
|
||
|
|
<br><br>
|
||
|
|
|
||
|
|
<a href="<?= $_SERVER['PHP_SELF'] ?>"><< Convert another file</a>
|
||
|
|
|