-
Notifications
You must be signed in to change notification settings - Fork 3
/
worked-hours.php
46 lines (41 loc) · 1.61 KB
/
worked-hours.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
<?php
declare(strict_types=1);
require_once(__DIR__ . '/../platform.php');
require_once(__DIR__ . '/helpers/createMovement.php');
require_once(__DIR__ . '/helpers/createStatement.php');
// E.g.: php src/cli-single.php worked-hours "20 September 2021" "stichting" "Peppol for the Masses" 4
// E.g.: php src/cli-single.php worked-hours "20 September 2021" "stichting" "Peppol for the Masses" 4 "Last hours"
function workedHours($context, $command)
{
if (isset($context["user"])) {
$conn = getDbConn();
$timestamp = strtotime($command[1]);
$worker = $context["user"]["username"];
$project = $command[2].':'.$command[3];
$type = 'worked';
$worked_hours = $command[4];
$description = (count($command) >= 6 ? $command[5] : "");
/* Create Movement */
$movementId = intval(createMovement($context, [
"create-movement",
$context["user"]["id"],
$type,
strval(getComponentId($worker)),
strval(getComponentId($project)),
$timestamp,
$worked_hours
])[0]);
$statementId = intval(createStatement($context, [
"create-statement",
$movementId,
$timestamp,
$description
])[0]);
$result = getMovementAndStatement($movementId, $statementId);
return $result;
// return [json_encode($command), "Created movement $movementId", "Created statement $statementId"];
//return [ "Created movement $movementId", "Created statement $statementId"];
} else {
return ["User not found or wrong password"];
}
}