-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.php
More file actions
67 lines (43 loc) · 1.66 KB
/
app.php
File metadata and controls
67 lines (43 loc) · 1.66 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
// To autoload prepared functionalities
include_once './includes/autoload.php';
$cmd = new CommandLine();
try {
// check if there is $orders
if (count($orders) == 0) {
$cmd->writeLine("No Data was found on the system!");
die();
}
$cmd->writeLine("Please choose order: [0-" . (count($orders) - 1) . ']');
// push options
foreach ($orders as $k => $order) {
$cmd->writeLine("[" . $k . "] ID: " . $order->id . " Price: " . $order->price);
}
// repeat the command unless valid option is entered!
orders_repeat:
$key = $cmd->readLine();
if (@$orders[$key] == null) {
$cmd->writeLine("Please choose a key in the reange !!!");
goto orders_repeat;
}
$order = @$orders[$key];
// find the client for the order!
$client = @(array_filter($clients, function($item) use ($order) {
return $item->id == $order->client_id;
}))[0];
$cmd->writeLine("Please choose communication type: [0-1]");
// comunication options: email and phone
$cmd->writeLine("[0] Phone: " . @$client->phone);
$cmd->writeLine("[1] Email: " . @$client->email);
comm_rep:
$key = $cmd->readLine();
if (!in_array($key, ["0", "1"])) {
$cmd->writeLine("Please choose a key in the range!!!");
goto comm_rep;
}
$cmd->writeLine("Thank you! you have chosen\n");
$cmd->writeLine(['Sending Client a notification by Phone', 'Sending Client a notification by Email'][$key]);
throw new Exception("We are sooo sorry! This app is not connected to any Service to be able to send the client a message");
} catch (\Exception $e) {
$cmd->error($e->getMessage());
}