This repository has been archived by the owner on Jun 27, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.php
77 lines (59 loc) · 1.88 KB
/
app.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
<?php
ini_set('display_errors', true);
set_time_limit(600);
session_start();
require 'config.php';
require 'vendor/autoload.php';
function dd($content) {
var_dump($content);
die();
}
function logThis($message) {
file_put_contents('sync.log', date('Y-m-d H:i:s') . ' - ' . $message . PHP_EOL, FILE_APPEND);
echo $message . PHP_EOL;
}
use Picqer\Api\Client as PicqerClient;
// Picqer connection
$picqerclient = new PicqerClient($config['picqer-company'], $config['picqer-apikey']);
if (!isset($_GET['step'])) {
header('Location: app.php?step=upload');
exit;
}
switch ($_GET['step']) {
case 'upload':
include('view-form.php');
break;
case 'preview':
if (is_uploaded_file($_FILES['file']['tmp_name'])) {
$excelextrator = new PicqerImporter\ExcelExtractor($config);
$orders = $excelextrator->processExcel(
$_FILES['file']['tmp_name'],
$_POST['customernumbers-rule'],
$_POST['productcode-column'],
$_POST['start-row'],
$_POST['start-column']
);
$_SESSION['orders'] = $orders;
$_SESSION['reference'] = $_POST['reference'];
include('view-preview.php');
} else {
include('view-no-data.php');
exit;
}
break;
case 'import':
if (!isset($_SESSION['orders']) || empty($_SESSION['orders'])) {
include('view-no-data.php');
exit;
}
$importer = new PicqerImporter\OrderImporter($picqerclient, $config);
$orderids = $importer->importOrders($_SESSION['orders'], $_SESSION['reference']);
unset($_SESSION['orders']);
include('view-done.php');
break;
case 'cancel':
unset($_SESSION['orders']);
header('Location: app.php?step=upload');
exit;
break;
}