2024-09-26 15:46:13 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
class ProjectPage extends Page {
|
|
|
|
|
public function getSteps() {
|
2024-09-26 19:14:20 +02:00
|
|
|
$steps = [];
|
2024-09-26 15:46:13 +02:00
|
|
|
|
2024-09-26 19:14:20 +02:00
|
|
|
foreach ($this->children() as $child) {
|
2024-11-16 11:30:51 +01:00
|
|
|
$steps[] = $this->createStep($child);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
usort($steps, fn($a, $b) => $a['index'] <=> $b['index']);
|
|
|
|
|
|
|
|
|
|
return $steps;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function createStep($child) {
|
|
|
|
|
$files = [];
|
|
|
|
|
$uri = null;
|
|
|
|
|
|
2024-11-19 13:59:06 +01:00
|
|
|
if (str_contains($child->stepName()->value(), 'Brief')) {
|
|
|
|
|
$this->handleBriefStep($child, $files, $uri);
|
2024-11-16 11:30:51 +01:00
|
|
|
}
|
|
|
|
|
|
2024-11-18 15:27:41 +01:00
|
|
|
if ($child->stepName() == 'proposal') {
|
|
|
|
|
$this->handleProposalStep($child, $files, $uri);
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-16 11:30:51 +01:00
|
|
|
if ($child->stepName() == 'virtualSample') {
|
|
|
|
|
$this->handleVirtualSampleStep($child, $files, $uri);
|
|
|
|
|
}
|
2024-10-16 17:32:15 +02:00
|
|
|
|
2024-11-16 11:30:51 +01:00
|
|
|
return [
|
|
|
|
|
'label' => $child->title()->value(),
|
|
|
|
|
'id' => $child->stepName()->value(),
|
2024-11-18 12:00:19 +01:00
|
|
|
'slug' => $child->slug(),
|
2024-11-16 11:30:51 +01:00
|
|
|
'index' => intval($child->stepIndex()->value()),
|
|
|
|
|
'modified' => $child->modified('Y-MM-dd'),
|
|
|
|
|
'uri' => $uri,
|
|
|
|
|
'files' => $files,
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-19 13:59:06 +01:00
|
|
|
private function handleBriefStep($child, &$files, &$uri) {
|
|
|
|
|
$uri = $child->uri();
|
|
|
|
|
|
2024-11-16 11:30:51 +01:00
|
|
|
if ($child->moodboard()->isNotEmpty()) {
|
2024-10-16 17:32:15 +02:00
|
|
|
foreach ($child->moodboard()->toFiles() as $file) {
|
2024-11-16 11:30:51 +01:00
|
|
|
$files[] = getFileData($file);
|
2024-10-16 18:43:04 +02:00
|
|
|
}
|
2024-09-26 19:14:20 +02:00
|
|
|
}
|
2024-09-26 15:46:13 +02:00
|
|
|
|
2024-11-16 11:30:51 +01:00
|
|
|
if ($child->pdf()->isNotEmpty()) {
|
2024-11-18 12:00:19 +01:00
|
|
|
$uri = $child->parent()->uri() . '?dialog=' . $child->slug();
|
2024-11-16 11:30:51 +01:00
|
|
|
$files[] = getFileData($child->pdf()->toFile());
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-11-18 15:27:41 +01:00
|
|
|
|
|
|
|
|
private function handleProposalStep($child, &$files, &$uri) {
|
|
|
|
|
$uri = $child->parent()->uri() . '?dialog=' . $child->slug();
|
|
|
|
|
if ($child->pdf()->isNotEmpty()) {
|
|
|
|
|
foreach ($child->pdf()->toFiles() as $file) {
|
|
|
|
|
$files[] = getFileData($file);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-09-26 18:46:33 +02:00
|
|
|
|
2024-11-16 11:30:51 +01:00
|
|
|
private function handleVirtualSampleStep($child, &$files, &$uri) {
|
2024-11-18 12:00:19 +01:00
|
|
|
$uri = $child->parent()->uri() . '?dialog=' . $child->slug();
|
2024-11-20 15:31:41 +01:00
|
|
|
|
|
|
|
|
if ($child->hasChildren()) {
|
|
|
|
|
$files['dynamic'] = [];
|
2024-11-20 08:26:12 +01:00
|
|
|
|
2024-11-20 15:31:41 +01:00
|
|
|
foreach ($child->children() as $key => $track) {
|
|
|
|
|
$trackData = [
|
|
|
|
|
'title' => (string) $track->title(),
|
|
|
|
|
'slug' => (string) $track->slug(),
|
|
|
|
|
'files' => [],
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
foreach ($track->views()->toFiles() as $view) {
|
|
|
|
|
$trackData['files'][] = getFileData($view);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$files['dynamic'][] = $trackData;
|
2024-11-20 08:26:12 +01:00
|
|
|
}
|
2024-11-20 15:31:41 +01:00
|
|
|
}
|
2024-11-20 08:26:12 +01:00
|
|
|
|
2024-11-20 15:31:41 +01:00
|
|
|
if ($child->rawGlass()->isNotEmpty() || $child->finishedGlass()->isNotEmpty()) {
|
|
|
|
|
$files['static'] = [];
|
|
|
|
|
}
|
2024-11-20 08:26:12 +01:00
|
|
|
|
2024-11-20 15:31:41 +01:00
|
|
|
if ($child->rawGlass()->isNotEmpty()) {
|
|
|
|
|
$files['static']['rawGlass'] = getFileData($child->rawGlass()->toFile());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($child->finishedGlass()->isNotEmpty()) {
|
|
|
|
|
$files['static']['finishedGlass'] = getFileData($child->finishedGlass()->toFile());
|
2024-11-16 11:30:51 +01:00
|
|
|
}
|
2024-09-26 15:46:13 +02:00
|
|
|
}
|
2024-11-11 11:43:34 +01:00
|
|
|
|
|
|
|
|
public function getStepLabel() {
|
|
|
|
|
$stepsLabel = [
|
|
|
|
|
"clientBrief" => "brief",
|
|
|
|
|
"proposal" => "offre commerciale",
|
|
|
|
|
"extendedBrief" => "brief enrichi",
|
|
|
|
|
"industrialIdeation" => "idéation industrielle",
|
|
|
|
|
"virtualSample" => "échantillon virtuel",
|
|
|
|
|
"physicalSample" => "échantillon physique",
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
return $stepsLabel[$this->currentStep()->value()];
|
|
|
|
|
}
|
2024-11-18 14:49:48 +01:00
|
|
|
|
|
|
|
|
public function printManagers() {
|
|
|
|
|
return A::implode($this->managers()->toUsers()->pluck('name'), ', ');
|
|
|
|
|
}
|
2024-09-26 15:46:13 +02:00
|
|
|
}
|