Files
api/services/nginx/app/routes/exampleRoute.php
T
Jeppe Bundgaard 9e58370e94 Add crop outline rendering and step counter refinement in machine_1
- Implement `drawCropOutLine` method for rendering horizontal crop outlines in machine images.
- Refactor `drawStepCounterOnButton` with dynamic font sizing and fallback handling for better text alignment.
- Add step counter rendering in top-right position for enhanced button visuals.
- Update `exampleRoute` debugging logic to integrate new `machine_1` functionality.
- Replace old debug assets with new button highlight state assets.
2026-01-29 15:18:37 +01:00

71 lines
2.7 KiB
PHP

<?php
namespace routes;
use classes\entra;
use classes\redis;
use dynamicimages\images\machine_1;
use goals\classes\goals;
use goals\classes\goals_criteria;
use objects\departments_o;
use objects\products_o;
use objects\users_o;
use traits\route_t;
class exampleRoute
{
use route_t;
public function run(): void
{
$this->get('/example', function () {
global $response;
// This is very hack-y, but it works for now
// Check if it's monday
if ((int)date('N') === 1) {
// Check if the time is between 06:00 and 17:00
if (!redis->exists('system:last_sent_monday_message') && (date('H') >= 6 && date('H') < 17)) {
// Set the key to expire in 24 hours
redis->set('system:last_sent_monday_message', date('Y-m-d H:i:s'));
redis->expire('system:last_sent_monday_message', 86400);
// Send the messages
$departments = [
1,
2,
3,
4,
5,
6,
7,
];
foreach ($departments as $department_id) {
$department = (new departments_o())->select((int)$department_id);
$days = 7;
// The time should be from 00:00:00 of the start date to 23:59:59 of the end date
$date_end = date('Y-m-d 23:59:59', strtotime("-1 days")); // Yesterday (Sunday) at 23:59:59
$date_start = date('Y-m-d 00:00:00', strtotime("-$days days")); // $days ago at 00:00:00
$department->sendPeriodStatisticsToSlack($date_start, $date_end); // Sends message to "daglig-ledelse".
}
$department->sendSlackInternalStatisticNotification($date_start, $date_end, $departments);
}
}
$response->success(['message' => 'Hello World!']);
});
$this->get('/debug', function () {
global $response;
//$response->success(['message' => 'Debugging route!']);
$machine_1 = new machine_1();
//$machine_1->debugAssets();
$machine_1->current_step = 0;
$machine_1->only_generate_current_step = false;
$machine_1->highlighted_buttons = [
0, 2, 4, 7
];
$machine_1->setup();
$machine_1->servePicture();
exit;
$response->success(['message' => 'Debugging route!', 'base64_image' => $machine_1->exportAsBase64()]);
});
}
}