-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.php
More file actions
54 lines (40 loc) · 1.3 KB
/
app.php
File metadata and controls
54 lines (40 loc) · 1.3 KB
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
#!/usr/bin/env php
<?php
require __DIR__.'/vendor/autoload.php';
require_once __DIR__.'/App.php';
use App\App;
$app = new App();
$options = getopt('', ['without-documents', 'with-documents']);
if (!isset($stdin)) $stdin = fopen('php://stdin', 'r');
if (!isset($stdout)) $stdout = fopen('php://stdout', 'w');
if (empty($options)) {
fwrite($stdout, "Usage:\n\tphp app.php [options]\n\nOptions:\n\t--with-documents\n\t--without-documents\n");
exit;
}
fwrite($stdout, "Please enter start date: ");
$dateStart = fgets($stdin);
if (!$app->setDateStart($dateStart)) {
fwrite($stdout, "Invalid date. Please use format YYYY.MM.DD\n");
exit;
}
fwrite($stdout, "Please enter end date: ");
$dateFinish = fgets($stdin);
if (!$app->setDateFinish($dateFinish)) {
fwrite($stdout, "Invalid date. Please use format YYYY.MM.DD\n");
exit;
}
$app->setSourceOptions($options);
$arrPayments = $app->getPayments();
printf("\n");
$headerPrinted = false;
foreach ($arrPayments as $arrPayment) {
printf("-----------------------\n");
if (!$headerPrinted) {
printf("|%-10s|%-10s|\n", 'count', 'amount');
printf("-----------------------\n");
$headerPrinted = true;
}
printf("|%-10d|%-10g|\n", $arrPayment['count'], $arrPayment['amount']);
}
printf("-----------------------\n");
exit;