bug fixes and template adjustments

This commit is contained in:
Dennis Eichhorn 2021-07-31 17:20:49 +02:00
parent bb69727f9a
commit b355009f53
35 changed files with 2653 additions and 656 deletions

View File

@ -14,7 +14,7 @@ declare(strict_types=1);
namespace Modules\Surveys\Admin\Install;
use phpOMS\DataStorage\Database\DatabasePool;
use phpOMS\Application\ApplicationAbstract;
/**
* Navigation class.
@ -29,15 +29,15 @@ class Navigation
/**
* Install navigation providing
*
* @param string $path Module path
* @param DatabasePool $dbPool Database pool for database interaction
* @param string $path Module path
* @param ApplicationAbstract $app Application
*
* @return void
*
* @since 1.0.0
*/
public static function install(string $path, DatabasePool $dbPool) : void
public static function install(string $path, ApplicationAbstract $app) : void
{
\Modules\Navigation\Admin\Installer::installExternal($dbPool, ['path' => __DIR__ . '/Navigation.install.json']);
\Modules\Navigation\Admin\Installer::installExternal($app, ['path' => __DIR__ . '/Navigation.install.json']);
}
}

237
Admin/Install/db.json Normal file
View File

@ -0,0 +1,237 @@
{
"survey_template": {
"name": "survey_template",
"fields": {
"survey_template_id": {
"name": "survey_template_id",
"type": "INT",
"null": false,
"primary": true,
"autoincrement": true
},
"survey_template_virtual": {
"name": "survey_template_virtual",
"type": "VARCHAR(255)",
"null": false
},
"survey_template_status": {
"name": "survey_template_status",
"type": "TINYINT",
"null": false
},
"survey_template_public_result": {
"name": "survey_template_public_result",
"type": "TINYINT",
"null": false
},
"survey_template_start": {
"name": "survey_template_start",
"type": "DATETIME",
"null": true
},
"survey_template_end": {
"name": "survey_template_end",
"type": "DATETIME",
"null": true
},
"survey_template_created_by": {
"name": "survey_template_created_by",
"type": "INT",
"null": false,
"foreignTable": "account",
"foreignKey": "account_id"
},
"survey_template_created_at": {
"name": "survey_template_created_at",
"type": "DATETIME",
"null": false
}
}
},
"survey_template_l11n": {
"name": "survey_template_l11n",
"fields": {
"survey_template_l11n_id": {
"name": "survey_template_l11n_id",
"type": "INT",
"null": false,
"primary": true,
"autoincrement": true
},
"survey_template_l11n_title": {
"name": "survey_template_l11n_title",
"type": "VARCHAR(255)",
"null": false
},
"survey_template_l11n_description": {
"name": "survey_template_l11n_description",
"type": "TEXT",
"null": false
},
"survey_template_l11n_description_plain": {
"name": "survey_template_l11n_description_plain",
"type": "TEXT",
"null": false
},
"survey_template_l11n_template": {
"name": "survey_template_l11n_template",
"type": "INT",
"null": false,
"foreignTable": "survey_template",
"foreignKey": "survey_template_id"
},
"survey_template_l11n_language": {
"name": "survey_template_l11n_language",
"type": "VARCHAR(2)",
"default": null,
"null": true,
"foreignTable": "language",
"foreignKey": "language_639_1"
}
}
},
"survey_template_tag": {
"name": "survey_template_tag",
"fields": {
"survey_template_tag_id": {
"name": "survey_template_tag_id",
"type": "INT",
"null": false,
"primary": true,
"autoincrement": true
},
"survey_template_tag_dst": {
"name": "survey_template_tag_dst",
"type": "INT",
"null": false,
"foreignTable": "survey_template",
"foreignKey": "survey_template_id"
},
"survey_template_tag_src": {
"name": "survey_template_tag_src",
"type": "INT",
"null": false,
"foreignTable": "tag",
"foreignKey": "tag_id"
}
}
},
"survey_template_element": {
"name": "survey_template_element",
"fields": {
"survey_template_element_id": {
"name": "survey_template_element_id",
"type": "INT",
"null": false,
"primary": true,
"autoincrement": true
},
"survey_template_element_type": {
"name": "survey_template_element_type",
"type": "TINYINT",
"null": false
},
"survey_template_element_optional": {
"name": "survey_template_element_optional",
"type": "TINYINT(1)",
"null": false
},
"survey_template_element_order": {
"name": "survey_template_element_order",
"type": "INT",
"null": false
},
"survey_template_element_values": {
"name": "survey_template_element_values",
"type": "TEXT",
"null": false
},
"survey_template_element_template": {
"name": "survey_template_element_template",
"type": "INT",
"null": false,
"foreignTable": "survey_template",
"foreignKey": "survey_template_id"
}
}
},
"survey_template_element_l11n": {
"name": "survey_template_element_l11n",
"fields": {
"survey_template_element_l11n_id": {
"name": "survey_template_element_l11n_id",
"type": "INT",
"null": false,
"primary": true,
"autoincrement": true
},
"survey_template_element_l11n_text": {
"name": "survey_template_element_l11n_text",
"type": "VARCHAR(255)",
"null": false
},
"survey_template_element_l11n_description": {
"name": "survey_template_element_l11n_description",
"type": "TEXT",
"null": false
},
"survey_template_element_l11n_description_plain": {
"name": "survey_template_element_l11n_description_plain",
"type": "TEXT",
"null": false
},
"survey_template_element_l11n_element": {
"name": "survey_template_element_l11n_element",
"type": "INT",
"null": false,
"foreignTable": "survey_template_element",
"foreignKey": "survey_template_element_id"
},
"survey_template_element_l11n_language": {
"name": "survey_template_element_l11n_language",
"type": "VARCHAR(2)",
"default": null,
"null": true,
"foreignTable": "language",
"foreignKey": "language_639_1"
}
}
},
"survey_template_element_label_l11n": {
"name": "survey_template_element_label_l11n",
"fields": {
"survey_template_element_label_l11n_id": {
"name": "survey_template_element_label_l11n_id",
"type": "INT",
"null": false,
"primary": true,
"autoincrement": true
},
"survey_template_element_label_l11n_title": {
"name": "survey_template_element_label_l11n_title",
"type": "VARCHAR(255)",
"null": false
},
"survey_template_element_label_l11n_order": {
"name": "survey_template_element_label_l11n_order",
"type": "INT",
"null": false
},
"survey_template_element_label_l11n_element": {
"name": "survey_template_element_label_l11n_element",
"type": "INT",
"null": false,
"foreignTable": "survey_template_element",
"foreignKey": "survey_template_element_id"
},
"survey_template_element_label_l11n_language": {
"name": "survey_template_element_label_l11n_language",
"type": "VARCHAR(2)",
"default": null,
"null": true,
"foreignTable": "language",
"foreignKey": "language_639_1"
}
}
}
}

View File

@ -6,6 +6,17 @@ use phpOMS\Account\PermissionType;
use phpOMS\Router\RouteVerb;
return [
'^.*/survey.*$' => [
[
'dest' => '\Modules\Surveys\Controller\BackendController:setUpBackend',
'verb' => RouteVerb::GET,
'permission' => [
'module' => BackendController::MODULE_NAME,
'type' => PermissionType::READ,
'state' => PermissionState::SURVEY_ANSWER,
],
],
],
'^.*/survey/list.*$' => [
[
'dest' => '\Modules\Surveys\Controller\BackendController:viewSurveysList',
@ -13,7 +24,7 @@ return [
'permission' => [
'module' => BackendController::MODULE_NAME,
'type' => PermissionType::READ,
'state' => PermissionState::SURVEY,
'state' => PermissionState::SURVEY_TEMPLATE,
],
],
],
@ -24,18 +35,29 @@ return [
'permission' => [
'module' => BackendController::MODULE_NAME,
'type' => PermissionType::CREATE,
'state' => PermissionState::SURVEY,
'state' => PermissionState::SURVEY_TEMPLATE,
],
],
],
'^.*/survey/profile.*$' => [
'^.*/survey/edit.*$' => [
[
'dest' => '\Modules\Surveys\Controller\BackendController:viewSurveysProfile',
'dest' => '\Modules\Surveys\Controller\BackendController:viewSurveysEdit',
'verb' => RouteVerb::GET,
'permission' => [
'module' => BackendController::MODULE_NAME,
'type' => PermissionType::READ,
'state' => PermissionState::SURVEY,
'state' => PermissionState::SURVEY_TEMPLATE,
],
],
],
'^.*/survey(\?.*|$)$' => [
[
'dest' => '\Modules\Surveys\Controller\BackendController:viewSurveysSurvey',
'verb' => RouteVerb::GET,
'permission' => [
'module' => BackendController::MODULE_NAME,
'type' => PermissionType::READ,
'state' => PermissionState::SURVEY_ANSWER,
],
],
],

View File

@ -0,0 +1,297 @@
<?php
/**
* Orange Management
*
* PHP Version 8.0
*
* @package Modules\Surveys
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace Modules\Surveys\Controller;
use Modules\Admin\Models\NullAccount;
use Modules\Tag\Models\NullTag;
use Modules\Surveys\Models\SurveyTemplate;
use Modules\Surveys\Models\SurveyTemplateL11n;
use Modules\Surveys\Models\SurveyTemplateLabelL11n;
use Modules\Surveys\Models\SurveyTemplateElement;
use Modules\Surveys\Models\SurveyTemplateElementL11n;
use Modules\Surveys\Models\SurveyTemplateElementMapper;
use Modules\Surveys\Models\SurveyTemplateMapper;
use Modules\Surveys\Models\SurveyStatus;
use Modules\Surveys\Models\SurveyElementType;
use phpOMS\Message\Http\HttpResponse;
use phpOMS\Message\Http\RequestStatusCode;
use phpOMS\Message\NotificationLevel;
use phpOMS\Message\RequestAbstract;
use phpOMS\Message\ResponseAbstract;
use phpOMS\Model\Message\FormValidation;
use phpOMS\Utils\Parser\Markdown\Markdown;
use phpOMS\Localization\ISO639x1Enum;
use Modules\Surveys\Models\SurveyAnswer;
/**
* Api controller for the survey module.
*
* @package Modules\Surveys
* @license OMS License 1.0
* @link https://orange-management.org
* @since 1.0.0
*/
final class ApiController extends Controller
{
/**
* Validate survey create request
*
* @param RequestAbstract $request Request
*
* @return array<string, bool> Returns the validation array of the request
*
* @since 1.0.0
*/
private function validateSurveyTemplateCreate(RequestAbstract $request) : array
{
$val = [];
if (($val['title'] = empty($request->getData('title')))
) {
return $val;
}
return [];
}
/**
* Api method to create a survey
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param mixed $data Generic data
*
* @return void
*
* @api
*
* @since 1.0.0
*/
public function apiSurveyTemplateCreate(RequestAbstract $request, ResponseAbstract $response, $data = null) : void
{
if (!empty($val = $this->validateSurveyTemplateCreate($request))) {
$response->set($request->uri->__toString(), new FormValidation($val));
$response->header->status = RequestStatusCode::R_400;
return;
}
$survey = $this->createSurveyTemplateFromRequest($request);
$this->createModel($request->header->account, $survey, SurveyTemplateMapper::class, 'survey', $request->getOrigin());
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'SurveyTemplate', 'SurveyTemplate successfully created.', $survey);
}
/**
* Method to create survey from request.
*
* @param RequestAbstract $request Request
*
* @return SurveyTemplate Returns the created survey from the request
*
* @since 1.0.0
*/
public function createSurveyTemplateFromRequest(RequestAbstract $request) : SurveyTemplate
{
$template = new SurveyTemplate();
$template->start = empty($request->getData('start')) ? null : new \DateTime($request->getData('start'));
$template->end = empty($request->getData('end')) ? null : new \DateTime($request->getData('end'));
$template->status = $request->getData('status') ?? SurveyStatus::ACTIVE;
$template->createdBy = new NullAccount($request->header->account);
$l11n = new SurveyTemplateL11n(
$request->getData('title') ?? '',
Markdown::parse((string) ($request->getData('description') ?? '')),
$request->getData('description') ?? '',
$request->getData('language') ?? ISO639x1Enum::_EN
);
$template->setL11n($l11n);
if (!empty($tags = $request->getDataJson('tags'))) {
foreach ($tags as $tag) {
if (!isset($tag['id'])) {
$request->setData('title', $tag['title'], true);
$request->setData('color', $tag['color'], true);
$request->setData('icon', $tag['icon'] ?? null, true);
$request->setData('language', $tag['language'], true);
$internalResponse = new HttpResponse();
$this->app->moduleManager->get('Tag')->apiTagCreate($request, $internalResponse, null);
$template->addTag($internalResponse->get($request->uri->__toString())['response']);
} else {
$template->addTag(new NullTag((int) $tag['id']));
}
}
}
return $template;
}
/**
* Validate task create request
*
* @param RequestAbstract $request Request
*
* @return array<string, bool> Returns the validation array of the request
*
* @since 1.0.0
*/
private function validateSurveyTemplateElementCreate(RequestAbstract $request) : array
{
$val = [];
if (($val['survey'] = empty((int) ($request->getData('survey'))))
|| ($val['type'] = !SurveyElementType::isValidValue((int) ($request->getData('type') ?? -1)))
|| ($val['labels_values'] = (($lCount = \count($request->getDataJson('labels'))) > 0
&& \count($request->getDataJson('values')) !== $lCount)
)
) {
return $val;
}
return [];
}
/**
* Api method to create a element
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param mixed $data Generic data
*
* @return void
*
* @api
*
* @since 1.0.0
*/
public function apiSurveyTemplateElementCreate(RequestAbstract $request, ResponseAbstract $response, $data = null) : void
{
if (!empty($val = $this->validateSurveyTemplateElementCreate($request))) {
$response->set($request->uri->__toString(), new FormValidation($val));
$response->header->status = RequestStatusCode::R_400;
return;
}
$element = $this->createSurveyTemplateElementFromRequest($request);
$this->createModel($request->header->account, $element, SurveyTemplateElementMapper::class, 'element', $request->getOrigin());
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'SurveyTemplateElement', 'SurveyTemplateElement successfully created.', $element);
}
/**
* Method to create element from request.
*
* @param RequestAbstract $request Request
*
* @return SurveyTemplateElement Returns the created element from the request
*
* @since 1.0.0
*/
public function createSurveyTemplateElementFromRequest(RequestAbstract $request) : SurveyTemplateElement
{
$element = new SurveyTemplateElement();
$element->type = (int) $request->getData('type');
$element->isOptional = (bool) ($request->getData('optional') ?? false);
$element->order = (int) ($request->getData('order') ?? 0);
$element->template = (int) ($request->getData('survey') ?? 0);
$l11n = new SurveyTemplateElementL11n(
$request->getData('text') ?? '',
Markdown::parse((string) ($request->getData('description') ?? '')),
$request->getData('description') ?? '',
$request->getData('language') ?? ISO639x1Enum::_EN
);
$element->setL11n($l11n);
$labels = $request->getDataJson('labels');
foreach ($labels as $text) {
$label = new SurveyTemplateLabelL11n(
$text,
$request->getData('language') ?? ISO639x1Enum::_EN
);
$element->addLabel($label);
}
$element->values = $request->getDataJson('values');
return $element;
}
/**
* Validate survey create request
*
* @param RequestAbstract $request Request
*
* @return array<string, bool> Returns the validation array of the request
*
* @since 1.0.0
*/
private function validateSurveyAnswerCreate(RequestAbstract $request) : array
{
$val = [];
if (($val['survey'] = empty($request->getData('survey')))
) {
return $val;
}
return [];
}
/**
* Api method to create a survey
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param mixed $data Generic data
*
* @return void
*
* @api
*
* @since 1.0.0
*/
public function apiSurveyAnswerCreate(RequestAbstract $request, ResponseAbstract $response, $data = null) : void
{
if (!empty($val = $this->validateSurveyAnswerCreate($request))) {
$response->set($request->uri->__toString(), new FormValidation($val));
$response->header->status = RequestStatusCode::R_400;
return;
}
$survey = $this->createSurveyAnswerFromRequest($request);
//$this->createModel($request->header->account, $survey, SurveyAnswerMapper::class, 'survey', $request->getOrigin());
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'SurveyAnswer', 'SurveyAnswer successfully created.', $survey);
}
/**
* Method to create survey from request.
*
* @param RequestAbstract $request Request
*
* @return SurveyAnswer Returns the created survey from the request
*
* @since 1.0.0
*/
public function createSurveyAnswerFromRequest(RequestAbstract $request) : SurveyAnswer
{
$answer = new SurveyAnswer();
$values = $request->getLike('e_\d');
return $answer;
}
}

View File

@ -18,6 +18,9 @@ use phpOMS\Contract\RenderableInterface;
use phpOMS\Message\RequestAbstract;
use phpOMS\Message\ResponseAbstract;
use phpOMS\Views\View;
use Modules\Surveys\Models\SurveyTemplateMapper;
use Modules\Media\Models\CollectionMapper;
use phpOMS\Asset\AssetType;
/**
* Surveys controller class.
@ -29,6 +32,24 @@ use phpOMS\Views\View;
*/
final class BackendController extends Controller
{
/**
* Routing end-point for application behaviour.
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param mixed $data Generic data
*
* @return void
*
* @since 1.0.0
* @codeCoverageIgnore
*/
public function setUpBackend(RequestAbstract $request, ResponseAbstract $response, $data = null) : void
{
$head = $response->get('Content')->getData('head');
$head->addAsset(AssetType::CSS, '/Modules/Surveys/Theme/Backend/styles.css');
}
/**
* Routing end-point for application behaviour.
*
@ -47,6 +68,17 @@ final class BackendController extends Controller
$view->setTemplate('/Modules/Surveys/Theme/Backend/surveys-list');
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1000801001, $request, $response));
$path = \str_replace('+', ' ', (string) ($request->getData('path') ?? '/'));
$surveys = SurveyTemplateMapper::with('language', $response->getLanguage())::getByVirtualPath($path);
list($collection, $parent) = CollectionMapper::getCollectionsByPath($path);
$view->addData('parent', $parent);
$view->addData('collections', $collection);
$view->addData('path', $path);
$view->addData('surveys', $surveys);
$view->addData('account', $this->app->accountManager->get($request->header->account));
return $view;
}
@ -83,10 +115,34 @@ final class BackendController extends Controller
* @since 1.0.0
* @codeCoverageIgnore
*/
public function viewSurveysProfile(RequestAbstract $request, ResponseAbstract $response, $data = null) : RenderableInterface
public function viewSurveysEdit(RequestAbstract $request, ResponseAbstract $response, $data = null) : RenderableInterface
{
$view = new View($this->app->l11nManager, $request, $response);
$view->setTemplate('/Modules/Surveys/Theme/Backend/surveys-profile');
$view->setTemplate('/Modules/Surveys/Theme/Backend/surveys-create');
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1000801001, $request, $response));
$survey = SurveyTemplateMapper::get($request->getData('id'));
$view->addData('survey', $survey);
return $view;
}
/**
* Routing end-point for application behaviour.
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param mixed $data Generic data
*
* @return RenderableInterface
*
* @since 1.0.0
* @codeCoverageIgnore
*/
public function viewSurveysSurvey(RequestAbstract $request, ResponseAbstract $response, $data = null) : RenderableInterface
{
$view = new View($this->app->l11nManager, $request, $response);
$view->setTemplate('/Modules/Surveys/Theme/Backend/surveys-survey');
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1000801001, $request, $response));
return $view;

View File

@ -1,114 +0,0 @@
<?php
/**
* Orange Management
*
* PHP Version 7.4
*
* @package Modules\Surveys\Models
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace Modules\Surveys\Models;
/**
* Answer class.
*
* @package Modules\Surveys\Models
* @license OMS License 1.0
* @link https://orange-management.org
* @since 1.0.0
*/
class Answer
{
/**
* ID.
*
* @var int
* @since 1.0.0
*/
private int $id = 0;
/**
* Name.
*
* @var string
* @since 1.0.0
*/
private string $name = '';
/**
* Description.
*
* @var string
* @since 1.0.0
*/
private string $description = '';
/**
* Get model id.
*
* @return int
*
* @since 1.0.0
*/
public function getId() : int
{
return $this->id;
}
/**
* Get answer name/title.
*
* @return string
*
* @since 1.0.0
*/
public function getName() : string
{
return $this->name;
}
/**
* Get name/title.
*
* @param string $name Name/title
*
* @return void
*
* @since 1.0.0
*/
public function setName(string $name) : void
{
$this->name = $name;
}
/**
* Get description.
*
* @return string
*
* @since 1.0.0
*/
public function getDescription() : string
{
return $this->description;
}
/**
* Set description.
*
* @param string $desc Description
*
* @return void
*
* @since 1.0.0
*/
public function setDescription(string $desc) : void
{
$this->description = $desc;
}
}

View File

@ -0,0 +1,39 @@
<?php
/**
* Orange Management
*
* PHP Version 8.0
*
* @package Modules\Surveys\Models
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace Modules\Surveys\Models;
/**
* Null model
*
* @package Modules\Surveys\Models
* @license OMS License 1.0
* @link https://orange-management.org
* @since 1.0.0
*/
final class NullSurveyTemplate extends SurveyTemplate
{
/**
* Constructor
*
* @param int $id Model id
*
* @since 1.0.0
*/
public function __construct(int $id = 0)
{
$this->id = $id;
parent::__construct();
}
}

View File

@ -0,0 +1,39 @@
<?php
/**
* Orange Management
*
* PHP Version 8.0
*
* @package Modules\Surveys\Models
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace Modules\Surveys\Models;
/**
* Null model
*
* @package Modules\Surveys\Models
* @license OMS License 1.0
* @link https://orange-management.org
* @since 1.0.0
*/
final class NullSurveyTemplateElement extends SurveyTemplateElement
{
/**
* Constructor
*
* @param int $id Model id
*
* @since 1.0.0
*/
public function __construct(int $id = 0)
{
$this->id = $id;
parent::__construct();
}
}

View File

@ -0,0 +1,39 @@
<?php
/**
* Orange Management
*
* PHP Version 8.0
*
* @package Modules\Surveys\Models
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace Modules\Surveys\Models;
/**
* Null model
*
* @package Modules\Surveys\Models
* @license OMS License 1.0
* @link https://orange-management.org
* @since 1.0.0
*/
final class NullSurveyTemplateElementL11n extends SurveyTemplateElementL11n
{
/**
* Constructor
*
* @param int $id Model id
*
* @since 1.0.0
*/
public function __construct(int $id = 0)
{
$this->id = $id;
parent::__construct();
}
}

View File

@ -0,0 +1,39 @@
<?php
/**
* Orange Management
*
* PHP Version 8.0
*
* @package Modules\Surveys\Models
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace Modules\Surveys\Models;
/**
* Null model
*
* @package Modules\Surveys\Models
* @license OMS License 1.0
* @link https://orange-management.org
* @since 1.0.0
*/
final class NullSurveyTemplateL11n extends SurveyTemplateL11n
{
/**
* Constructor
*
* @param int $id Model id
*
* @since 1.0.0
*/
public function __construct(int $id = 0)
{
$this->id = $id;
parent::__construct();
}
}

View File

@ -0,0 +1,39 @@
<?php
/**
* Orange Management
*
* PHP Version 8.0
*
* @package Modules\Surveys\Models
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace Modules\Surveys\Models;
/**
* Null model
*
* @package Modules\Surveys\Models
* @license OMS License 1.0
* @link https://orange-management.org
* @since 1.0.0
*/
final class NullSurveyTemplateLabelL11n extends SurveyTemplateLabelL11n
{
/**
* Constructor
*
* @param int $id Model id
*
* @since 1.0.0
*/
public function __construct(int $id = 0)
{
$this->id = $id;
parent::__construct();
}
}

View File

@ -26,5 +26,11 @@ use phpOMS\Stdlib\Base\Enum;
*/
abstract class PermissionState extends Enum
{
public const SURVEY = 1;
public const SURVEY_TEMPLATE = 1;
public const SURVEY_ANSWER = 2;
public const SURVEY_PUBLIC_STATISTICS = 3;
public const SURVEY_ADMIN_STATISTICS = 4;
}

View File

@ -1,114 +0,0 @@
<?php
/**
* Orange Management
*
* PHP Version 7.4
*
* @package Modules\Surveys\Models
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace Modules\Surveys\Models;
/**
* Question class.
*
* @package Modules\Surveys\Models
* @license OMS License 1.0
* @link https://orange-management.org
* @since 1.0.0
*/
class Question
{
/**
* ID.
*
* @var int
* @since 1.0.0
*/
private int $id = 0;
/**
* Name.
*
* @var string
* @since 1.0.0
*/
private string $name = '';
/**
* Description.
*
* @var string
* @since 1.0.0
*/
private string $description = '';
/**
* Get id.
*
* @return int
*
* @since 1.0.0
*/
public function getId() : int
{
return $this->id;
}
/**
* Get name/title.
*
* @return string
*
* @since 1.0.0
*/
public function getName() : string
{
return $this->name;
}
/**
* Set name/title.
*
* @param string $name Name/title
*
* @return void
*
* @since 1.0.0
*/
public function setName(string $name) : void
{
$this->name = $name;
}
/**
* Get string.
*
* @return string
*
* @since 1.0.0
*/
public function getDescription() : string
{
return $this->description;
}
/**
* Set description.
*
* @param string $desc Description
*
* @return void
*
* @since 1.0.0
*/
public function setDescription($desc) : void
{
$this->description = $desc;
}
}

View File

@ -1,114 +0,0 @@
<?php
/**
* Orange Management
*
* PHP Version 7.4
*
* @package Modules\Surveys\Models
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace Modules\Surveys\Models;
/**
* Section class.
*
* @package Modules\Surveys\Models
* @license OMS License 1.0
* @link https://orange-management.org
* @since 1.0.0
*/
class Section
{
/**
* ID.
*
* @var int
* @since 1.0.0
*/
private int $id = 0;
/**
* Name.
*
* @var string
* @since 1.0.0
*/
private string $name = '';
/**
* Description.
*
* @var string
* @since 1.0.0
*/
private string $description = '';
/**
* Get id.
*
* @return int
*
* @since 1.0.0
*/
public function getId() : int
{
return $this->id;
}
/**
* Get name.
*
* @return string
*
* @since 1.0.0
*/
public function getName() : string
{
return $this->name;
}
/**
* Set name.
*
* @param string $name Name
*
* @return void
*
* @since 1.0.0
*/
public function setName(string $name) : void
{
$this->name = $name;
}
/**
* Get description.
*
* @return string
*
* @since 1.0.0
*/
public function getDescription() : string
{
return $this->description;
}
/**
* Set description.
*
* @param string $desc Description
*
* @return void
*
* @since 1.0.0
*/
public function setDescription(string $desc) : void
{
$this->description = $desc;
}
}

View File

@ -1,190 +0,0 @@
<?php
/**
* Orange Management
*
* PHP Version 7.4
*
* @package Modules\Surveys\Models
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace Modules\Surveys\Models;
/**
* Survey class.
*
* @package Modules\Surveys\Models
* @license OMS License 1.0
* @link https://orange-management.org
* @since 1.0.0
*/
class Survey
{
/**
* ID.
*
* @var int
* @since 1.0.0
*/
private int $id = 0;
/**
* Name.
*
* @var string
* @since 1.0.0
*/
private string $name = '';
/**
* Description.
*
* @var string
* @since 1.0.0
*/
private string $description = '';
/**
* Created.
*
* @var \DateTime
* @since 1.0.0
*/
private \DateTime $created;
/**
* Creator.
*
* @var int
* @since 1.0.0
*/
private ?int $creator = null;
/**
* Constructor.
*
* @since 1.0.0
*/
public function __construct()
{
$this->created = new \DateTime('now');
}
/**
* Get id.
*
* @return int
*
* @since 1.0.0
*/
public function getId() : int
{
return $this->id;
}
/**
* Get name/title.
*
* @return string
*
* @since 1.0.0
*/
public function getName() : string
{
return $this->name;
}
/**
* Set name/title.
*
* @param string $name Name/title
*
* @return void
*
* @since 1.0.0
*/
public function setName(string $name) : void
{
$this->name = $name;
}
/**
* Get description.
*
* @return string
*
* @since 1.0.0
*/
public function getDescription() : string
{
return $this->description;
}
/**
* Set description.
*
* @param string $desc Description
*
* @return void
*
* @since 1.0.0
*/
public function setDescription(string $desc) : void
{
$this->description = $desc;
}
/**
* Get created.
*
* @return \DateTime
*
* @since 1.0.0
*/
public function getCreated() : \DateTime
{
return $this->created;
}
/**
* Set created.
*
* @return void
*
* @since 1.0.0
*/
public function setCreated($created) : void
{
$this->created = $created;
}
/**
* Get creator.
*
* @return mixed
*
* @since 1.0.0
*/
public function getCreator()
{
return $this->creator;
}
/**
* Set creator.
*
* @param mixed $creator Creator
*
* @return void
*
* @since 1.0.0
*/
public function setCreator($creator) : void
{
$this->creator = $creator;
}
}

35
Models/SurveyAnswer.php Normal file
View File

@ -0,0 +1,35 @@
<?php
/**
* Orange Management
*
* PHP Version 8.0
*
* @package Modules\Surveys\Models
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace Modules\Surveys\Models;
/**
* Null model
*
* @package Modules\Surveys\Models
* @license OMS License 1.0
* @link https://orange-management.org
* @since 1.0.0
*/
final class SurveyAnswer
{
/**
* Constructor
*
* @since 1.0.0
*/
public function __construct()
{
}
}

View File

@ -0,0 +1,44 @@
<?php
/**
* Orange Management
*
* PHP Version 8.0
*
* @package Modules\Surveys\Models
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace Modules\Surveys\Models;
use phpOMS\Stdlib\Base\Enum;
/**
* Task status enum.
*
* @package Modules\Surveys\Models
* @license OMS License 1.0
* @link https://orange-management.org
* @since 1.0.0
*/
abstract class SurveyElementType extends Enum
{
public const HEADLINE = 1;
public const DROPDOWN = 2;
public const CHECKBOX = 3;
public const RADIO = 4;
public const TEXTFIELD = 5;
public const TEXTAREA = 6;
public const NUMERIC = 7;
public const DATE = 8;
}

30
Models/SurveyStatus.php Normal file
View File

@ -0,0 +1,30 @@
<?php
/**
* Orange Management
*
* PHP Version 8.0
*
* @package Modules\Surveys\Models
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace Modules\Surveys\Models;
use phpOMS\Stdlib\Base\Enum;
/**
* Task status enum.
*
* @package Modules\Surveys\Models
* @license OMS License 1.0
* @link https://orange-management.org
* @since 1.0.0
*/
abstract class SurveyStatus extends Enum
{
public const ACTIVE = 1;
}

205
Models/SurveyTemplate.php Normal file
View File

@ -0,0 +1,205 @@
<?php
/**
* Orange Management
*
* PHP Version 7.4
*
* @package Modules\Surveys\Models
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace Modules\Surveys\Models;
use phpOMS\Localization\ISO639x1Enum;
use Modules\Admin\Models\Account;
use Modules\Tag\Models\Tag;
/**
* Survey class.
*
* @package Modules\Surveys\Models
* @license OMS License 1.0
* @link https://orange-management.org
* @since 1.0.0
*/
class SurveyTemplate
{
/**
* ID.
*
* @var int
* @since 1.0.0
*/
protected int $id = 0;
/**
* Status.
*
* @var int
* @since 1.0.0
*/
public int $status = SurveyStatus::ACTIVE;
/**
* Public result.
*
* Should the result of the survey be made public?
*
* @var int
* @since 1.0.0
*/
public bool $hasPublicResult = true;
/**
* Created.
*
* @var \DateTime
* @since 1.0.0
*/
public \DateTimeImmutable $createdAt;
/**
* Start.
*
* @var null|\DateTime
* @since 1.0.0
*/
public ?\DateTime $start = null;
/**
* End.
*
* @var null|\DateTime
* @since 1.0.0
*/
public ?\DateTime $end = null;
/**
* Creator.
*
* @var Account
* @since 1.0.0
*/
public Account $createdBy;
/**
* L11n.
*
* @var null|SurveyTemplateL11n
* @since 1.0.0
*/
protected ?SurveyTemplateL11n $l11n = null;
/**
* Path for organizing.
*
* @var string
* @since 1.0.0
*/
private string $virtualPath = '/';
/**
* Tags.
*
* @var Tag[]
* @since 1.0.0
*/
private array $tags = [];
/**
* Elements.
*
* @var SurveyTemplateElement[]
* @since 1.0.0
*/
private array $elements = [];
/**
* Constructor.
*
* @since 1.0.0
*/
public function __construct()
{
$this->createdAt = new \DateTimeImmutable('now');
}
/**
* Get id.
*
* @return int
*
* @since 1.0.0
*/
public function getId() : int
{
return $this->id;
}
/**
* @return SurveyTemplateL11n
*
* @since 1.0.0
*/
public function getL11n() : SurveyTemplateL11n
{
return $this->l11n;
}
/**
* Set l11n
*
* @param SurveyTemplateL11n $l11n Template l11n
* @param string $lang Language
*
* @return void
*
* @since 1.0.0
*/
public function setL11n(SurveyTemplateL11n $l11n, string $lang = ISO639x1Enum::_EN) : void
{
$this->l11n = $l11n;
}
/**
* Get tags
*
* @return array
*
* @since 1.0.0
*/
public function getTags() : array
{
return $this->tags;
}
/**
* Add tag
*
* @param Tag $tag Tag
*
* @return void
*
* @since 1.0.0
*/
public function addTag(Tag $tag) : void
{
$this->tags[] = $tag;
}
/**
* Get elements
*
* @return array
*
* @since 1.0.0
*/
public function getElements() : array
{
return $this->elements;
}
}

View File

@ -0,0 +1,161 @@
<?php
/**
* Orange Management
*
* PHP Version 7.4
*
* @package Modules\Surveys\Models
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace Modules\Surveys\Models;
use phpOMS\Localization\ISO639x1Enum;
/**
* Survey class.
*
* @package Modules\Surveys\Models
* @license OMS License 1.0
* @link https://orange-management.org
* @since 1.0.0
*/
class SurveyTemplateElement
{
/**
* ID.
*
* @var int
* @since 1.0.0
*/
private int $id = 0;
/**
* Type.
*
* @var int
* @since 1.0.0
*/
public int $type = SurveyElementType::CHECKBOX;
/**
* Optional.
*
* @var bool
* @since 1.0.0
*/
public bool $isOptional = false;
/**
* Order.
*
* @var int
* @since 1.0.0
*/
public int $order = 0;
/**
* Template.
*
* @var int
* @since 1.0.0
*/
public int $template = 0;
/**
* L11n.
*
* @var null|SurveyTemplateElementL11n
* @since 1.0.0
*/
protected ?SurveyTemplateElementL11n $l11n = null;
/**
* Labels.
*
* @var SurveyTemplateLabelL11n[]
* @since 1.0.0
*/
protected array $labels = [];
/**
* Values.
*
* @var array
* @since 1.0.0
*/
public array $values = [];
/**
* Get id.
*
* @return int
*
* @since 1.0.0
*/
public function getId() : int
{
return $this->id;
}
/**
* @return SurveyTemplateElementL11n
*
* @since 1.0.0
*/
public function getL11n() : SurveyTemplateElementL11n
{
return $this->l11n ?? new NullSurveyTemplateElementL11n();
}
/**
* Set l11n
*
* @param SurveyTemplateElementL11n $l11n Template l11n
* @param string $lang Language
*
* @return void
*
* @since 1.0.0
*/
public function setL11n(SurveyTemplateElementL11n $l11n, string $lang = ISO639x1Enum::_EN) : void
{
$this->l11n = $l11n;
}
/**
* @param SurveyTemplateLabelL11n $label Label
*
* @return void
*
* @since 1.0.0
*/
public function addLabel(SurveyTemplateLabelL11n $label) : void
{
$this->labels[] = $label;
}
/**
* @return array
*
* @since 1.0.0
*/
public function getLabels() : array
{
return $this->labels;
}
/**
* @return array
*
* @since 1.0.0
*/
public function getValues() : array
{
return $this->values;
}
}

View File

@ -0,0 +1,182 @@
<?php
/**
* Orange Management
*
* PHP Version 8.0
*
* @package Modules\Surveys\Models
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace Modules\Surveys\Models;
use phpOMS\Contract\ArrayableInterface;
use phpOMS\Localization\ISO639x1Enum;
/**
* Surveys class.
*
* @package Modules\Surveys\Models
* @license OMS License 1.0
* @link https://orange-management.org
* @since 1.0.0
*/
class SurveyTemplateElementL11n implements \JsonSerializable, ArrayableInterface
{
/**
* ID.
*
* @var int
* @since 1.0.0
*/
protected int $id = 0;
/**
* Surveys ID.
*
* @var int
* @since 1.0.0
*/
protected int $element = 0;
/**
* Language.
*
* @var string
* @since 1.0.0
*/
protected string $language = ISO639x1Enum::_EN;
/**
* Title.
*
* @var string
* @since 1.0.0
*/
public string $text = '';
/**
* Description.
*
* @var string
* @since 1.0.0
*/
public string $description = '';
/**
* Description.
*
* @var string
* @since 1.0.0
*/
public string $descriptionPlain = '';
/**
* Constructor.
*
* @param string $text Title
* @param string $description Description
* @param string $descriptionPlain Description plain text
* @param string $language Language code
*
* @since 1.0.0
*/
public function __construct(string $text = '', string $description = '', string $descriptionPlain = '', string $language = ISO639x1Enum::_EN)
{
$this->text = $text;
$this->description = $description;
$this->descriptionPlain = $descriptionPlain;
$this->language = $language;
}
/**
* Get id
*
* @return int
*
* @since 1.0.0
*/
public function getId() : int
{
return $this->id;
}
/**
* Set element.
*
* @param int $element Surveys id
*
* @return void
*
* @since 1.0.0
*/
public function setElement(int $element) : void
{
$this->element = $element;
}
/**
* Get element
*
* @return int
*
* @since 1.0.0
*/
public function getElement() : int
{
return $this->element;
}
/**
* Get language
*
* @return string
*
* @since 1.0.0
*/
public function getLanguage() : string
{
return $this->language;
}
/**
* Set language
*
* @param string $language Language
*
* @return void
*
* @since 1.0.0
*/
public function setLanguage(string $language) : void
{
$this->language = $language;
}
/**
* {@inheritdoc}
*/
public function toArray() : array
{
return [
'id' => $this->id,
'text' => $this->text,
'description' => $this->description,
'descriptionPlain' => $this->descriptionPlain,
'element' => $this->element,
'language' => $this->language,
];
}
/**
* {@inheritdoc}
*/
public function jsonSerialize()
{
return $this->toArray();
}
}

View File

@ -0,0 +1,59 @@
<?php
/**
* Orange Management
*
* PHP Version 8.0
*
* @package Modules\Surveys\Models
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace Modules\Surveys\Models;
use phpOMS\DataStorage\Database\DataMapperAbstract;
/**
* Tag mapper class.
*
* @package Modules\Surveys\Models
* @license OMS License 1.0
* @link https://orange-management.org
* @since 1.0.0
*/
final class SurveyTemplateElementL11nMapper extends DataMapperAbstract
{
/**
* Columns.
*
* @var array<string, array{name:string, type:string, internal:string, autocomplete?:bool, readonly?:bool, writeonly?:bool, annotations?:array}>
* @since 1.0.0
*/
protected static array $columns = [
'survey_template_element_l11n_id' => ['name' => 'survey_template_element_l11n_id', 'type' => 'int', 'internal' => 'id'],
'survey_template_element_l11n_text' => ['name' => 'survey_template_element_l11n_text', 'type' => 'string', 'internal' => 'text', 'autocomplete' => true],
'survey_template_element_l11n_description' => ['name' => 'survey_template_element_l11n_description', 'type' => 'string', 'internal' => 'description'],
'survey_template_element_l11n_description_plain' => ['name' => 'survey_template_element_l11n_description_plain', 'type' => 'string', 'internal' => 'descriptionPlain'],
'survey_template_element_l11n_element' => ['name' => 'survey_template_element_l11n_element', 'type' => 'int', 'internal' => 'element'],
'survey_template_element_l11n_language' => ['name' => 'survey_template_element_l11n_language', 'type' => 'string', 'internal' => 'language'],
];
/**
* Primary table.
*
* @var string
* @since 1.0.0
*/
protected static string $table = 'survey_template_element_l11n';
/**
* Primary field name.
*
* @var string
* @since 1.0.0
*/
protected static string $primaryField = 'survey_template_element_l11n_id';
}

View File

@ -0,0 +1,95 @@
<?php
/**
* Orange Management
*
* PHP Version 8.0
*
* @package Modules\Surveys\Models
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace Modules\Surveys\Models;
use Modules\Admin\Models\AccountMapper;
use Modules\Media\Models\CollectionMapper;
use Modules\Media\Models\MediaMapper;
use Modules\Tag\Models\TagMapper;
use phpOMS\DataStorage\Database\DataMapperAbstract;
use phpOMS\DataStorage\Database\RelationType;
/**
* Mapper class.
*
* @package Modules\Surveys\Models
* @license OMS License 1.0
* @link https://orange-management.org
* @since 1.0.0
*/
final class SurveyTemplateElementMapper extends DataMapperAbstract
{
/**
* Columns.
*
* @var array<string, array{name:string, type:string, internal:string, autocomplete?:bool, readonly?:bool, writeonly?:bool, annotations?:array}>
* @since 1.0.0
*/
protected static array $columns = [
'survey_template_element_id' => ['name' => 'survey_template_element_id', 'type' => 'int', 'internal' => 'id'],
'survey_template_element_type' => ['name' => 'survey_template_element_type', 'type' => 'int', 'internal' => 'type'],
'survey_template_element_order' => ['name' => 'survey_template_element_order', 'type' => 'int', 'internal' => 'order'],
'survey_template_element_optional' => ['name' => 'survey_template_element_optional', 'type' => 'bool', 'internal' => 'isOptional'],
'survey_template_element_values' => ['name' => 'survey_template_element_values', 'type' => 'Json', 'internal' => 'values'],
'survey_template_element_template' => ['name' => 'survey_template_element_template', 'type' => 'int', 'internal' => 'template'],
];
/**
* Has many relation.
*
* @var array<string, array{mapper:string, table:string, self?:?string, external?:?string, column?:string}>
* @since 1.0.0
*/
protected static array $hasMany = [
'l11n' => [
'mapper' => SurveyTemplateElementL11nMapper::class,
'table' => 'survey_template_element_l11n',
'self' => 'survey_template_element_l11n_element',
'conditional' => true,
'external' => null,
],
'labels' => [
'mapper' => SurveyTemplateLabelL11nMapper::class,
'table' => 'survey_template_element_label_l11n',
'self' => 'survey_template_element_label_l11n_element',
'conditional' => true,
'external' => null,
],
];
/**
* Primary table.
*
* @var string
* @since 1.0.0
*/
protected static string $table = 'survey_template_element';
/**
* Created at.
*
* @var string
* @since 1.0.0
*/
protected static string $createdAt = 'survey_template_element_created_at';
/**
* Primary field name.
*
* @var string
* @since 1.0.0
*/
protected static string $primaryField = 'survey_template_element_id';
}

View File

@ -0,0 +1,181 @@
<?php
/**
* Orange Management
*
* PHP Version 8.0
*
* @package Modules\Surveys\Models
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace Modules\Surveys\Models;
use phpOMS\Contract\ArrayableInterface;
use phpOMS\Localization\ISO639x1Enum;
/**
* Surveys class.
*
* @package Modules\Surveys\Models
* @license OMS License 1.0
* @link https://orange-management.org
* @since 1.0.0
*/
class SurveyTemplateL11n implements \JsonSerializable, ArrayableInterface
{
/**
* ID.
*
* @var int
* @since 1.0.0
*/
protected int $id = 0;
/**
* Surveys ID.
*
* @var int
* @since 1.0.0
*/
protected int $template = 0;
/**
* Language.
*
* @var string
* @since 1.0.0
*/
protected string $language = ISO639x1Enum::_EN;
/**
* Title.
*
* @var string
* @since 1.0.0
*/
public string $title = '';
/**
* Description.
*
* @var string
* @since 1.0.0
*/
public string $description = '';
/**
* Description.
*
* @var string
* @since 1.0.0
*/
public string $descriptionPlain = '';
/**
* Constructor.
*
* @param string $title Title
* @param string $description Description
* @param string $descriptionPlain Plain description
* @param string $language Language code
*
* @since 1.0.0
*/
public function __construct(string $title = '', string $description = '', string $descriptionPlain = '', string $language = ISO639x1Enum::_EN)
{
$this->title = $title;
$this->description = $description;
$this->descriptionPlain = $descriptionPlain;
$this->language = $language;
}
/**
* Get id
*
* @return int
*
* @since 1.0.0
*/
public function getId() : int
{
return $this->id;
}
/**
* Set template.
*
* @param int $template Surveys id
*
* @return void
*
* @since 1.0.0
*/
public function setSurvey(int $template) : void
{
$this->template = $template;
}
/**
* Get template
*
* @return int
*
* @since 1.0.0
*/
public function getSurvey() : int
{
return $this->template;
}
/**
* Get language
*
* @return string
*
* @since 1.0.0
*/
public function getLanguage() : string
{
return $this->language;
}
/**
* Set language
*
* @param string $language Language
*
* @return void
*
* @since 1.0.0
*/
public function setLanguage(string $language) : void
{
$this->language = $language;
}
/**
* {@inheritdoc}
*/
public function toArray() : array
{
return [
'id' => $this->id,
'title' => $this->title,
'description' => $this->description,
'template' => $this->template,
'language' => $this->language,
];
}
/**
* {@inheritdoc}
*/
public function jsonSerialize()
{
return $this->toArray();
}
}

View File

@ -0,0 +1,59 @@
<?php
/**
* Orange Management
*
* PHP Version 8.0
*
* @package Modules\Surveys\Models
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace Modules\Surveys\Models;
use phpOMS\DataStorage\Database\DataMapperAbstract;
/**
* Tag mapper class.
*
* @package Modules\Surveys\Models
* @license OMS License 1.0
* @link https://orange-management.org
* @since 1.0.0
*/
final class SurveyTemplateL11nMapper extends DataMapperAbstract
{
/**
* Columns.
*
* @var array<string, array{name:string, type:string, internal:string, autocomplete?:bool, readonly?:bool, writeonly?:bool, annotations?:array}>
* @since 1.0.0
*/
protected static array $columns = [
'survey_template_l11n_id' => ['name' => 'survey_template_l11n_id', 'type' => 'int', 'internal' => 'id'],
'survey_template_l11n_title' => ['name' => 'survey_template_l11n_title', 'type' => 'string', 'internal' => 'title', 'autocomplete' => true],
'survey_template_l11n_description' => ['name' => 'survey_template_l11n_description', 'type' => 'string', 'internal' => 'description'],
'survey_template_l11n_description_plain' => ['name' => 'survey_template_l11n_description_plain', 'type' => 'string', 'internal' => 'descriptionPlain'],
'survey_template_l11n_template' => ['name' => 'survey_template_l11n_template', 'type' => 'int', 'internal' => 'template'],
'survey_template_l11n_language' => ['name' => 'survey_template_l11n_language', 'type' => 'string', 'internal' => 'language'],
];
/**
* Primary table.
*
* @var string
* @since 1.0.0
*/
protected static string $table = 'survey_template_l11n';
/**
* Primary field name.
*
* @var string
* @since 1.0.0
*/
protected static string $primaryField = 'survey_template_l11n_id';
}

View File

@ -0,0 +1,168 @@
<?php
/**
* Orange Management
*
* PHP Version 8.0
*
* @package Modules\Surveys\Models
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace Modules\Surveys\Models;
use phpOMS\Contract\ArrayableInterface;
use phpOMS\Localization\ISO639x1Enum;
/**
* Surveys class.
*
* @package Modules\Surveys\Models
* @license OMS License 1.0
* @link https://orange-management.org
* @since 1.0.0
*/
class SurveyTemplateLabelL11n implements \JsonSerializable, ArrayableInterface
{
/**
* ID.
*
* @var int
* @since 1.0.0
*/
protected int $id = 0;
/**
* element ID.
*
* @var int
* @since 1.0.0
*/
protected int $element = 0;
/**
* Order.
*
* @var int
* @since 1.0.0
*/
public int $order = 0;
/**
* Language.
*
* @var string
* @since 1.0.0
*/
protected string $language = ISO639x1Enum::_EN;
/**
* Title.
*
* @var string
* @since 1.0.0
*/
public string $title = '';
/**
* Constructor.
*
* @param string $title Title
* @param string $language Language code
*
* @since 1.0.0
*/
public function __construct(string $title = '', string $language = ISO639x1Enum::_EN)
{
$this->title = $title;
$this->language = $language;
}
/**
* Get id
*
* @return int
*
* @since 1.0.0
*/
public function getId() : int
{
return $this->id;
}
/**
* Set element.
*
* @param int $element Surveys id
*
* @return void
*
* @since 1.0.0
*/
public function setElement(int $element) : void
{
$this->element = $element;
}
/**
* Get element
*
* @return int
*
* @since 1.0.0
*/
public function getElement() : int
{
return $this->element;
}
/**
* Get language
*
* @return string
*
* @since 1.0.0
*/
public function getLanguage() : string
{
return $this->language;
}
/**
* Set language
*
* @param string $language Language
*
* @return void
*
* @since 1.0.0
*/
public function setLanguage(string $language) : void
{
$this->language = $language;
}
/**
* {@inheritdoc}
*/
public function toArray() : array
{
return [
'id' => $this->id,
'title' => $this->title,
'element' => $this->element,
'language' => $this->language,
];
}
/**
* {@inheritdoc}
*/
public function jsonSerialize()
{
return $this->toArray();
}
}

View File

@ -0,0 +1,58 @@
<?php
/**
* Orange Management
*
* PHP Version 8.0
*
* @package Modules\Surveys\Models
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace Modules\Surveys\Models;
use phpOMS\DataStorage\Database\DataMapperAbstract;
/**
* Tag mapper class.
*
* @package Modules\Surveys\Models
* @license OMS License 1.0
* @link https://orange-management.org
* @since 1.0.0
*/
final class SurveyTemplateLabelL11nMapper extends DataMapperAbstract
{
/**
* Columns.
*
* @var array<string, array{name:string, type:string, internal:string, autocomplete?:bool, readonly?:bool, writeonly?:bool, annotations?:array}>
* @since 1.0.0
*/
protected static array $columns = [
'survey_template_element_label_l11n_id' => ['name' => 'survey_template_element_label_l11n_id', 'type' => 'int', 'internal' => 'id'],
'survey_template_element_label_l11n_title' => ['name' => 'survey_template_element_label_l11n_title', 'type' => 'string', 'internal' => 'title', 'autocomplete' => true],
'survey_template_element_label_l11n_element' => ['name' => 'survey_template_element_label_l11n_element', 'type' => 'int', 'internal' => 'element'],
'survey_template_element_label_l11n_order' => ['name' => 'survey_template_element_label_l11n_order', 'type' => 'int', 'internal' => 'order'],
'survey_template_element_label_l11n_language' => ['name' => 'survey_template_element_label_l11n_language', 'type' => 'string', 'internal' => 'language'],
];
/**
* Primary table.
*
* @var string
* @since 1.0.0
*/
protected static string $table = 'survey_template_element_label_l11n';
/**
* Primary field name.
*
* @var string
* @since 1.0.0
*/
protected static string $primaryField = 'survey_template_element_label_l11n_id';
}

View File

@ -0,0 +1,133 @@
<?php
/**
* Orange Management
*
* PHP Version 8.0
*
* @package Modules\Surveys\Models
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace Modules\Surveys\Models;
use Modules\Admin\Models\AccountMapper;
use Modules\Media\Models\CollectionMapper;
use Modules\Media\Models\MediaMapper;
use Modules\Tag\Models\TagMapper;
use phpOMS\DataStorage\Database\DataMapperAbstract;
use phpOMS\DataStorage\Database\RelationType;
/**
* Mapper class.
*
* @package Modules\Surveys\Models
* @license OMS License 1.0
* @link https://orange-management.org
* @since 1.0.0
*/
final class SurveyTemplateMapper extends DataMapperAbstract
{
/**
* Columns.
*
* @var array<string, array{name:string, type:string, internal:string, autocomplete?:bool, readonly?:bool, writeonly?:bool, annotations?:array}>
* @since 1.0.0
*/
protected static array $columns = [
'survey_template_id' => ['name' => 'survey_template_id', 'type' => 'int', 'internal' => 'id'],
'survey_template_status' => ['name' => 'survey_template_status', 'type' => 'int', 'internal' => 'status'],
'survey_template_public_result' => ['name' => 'survey_template_public_result', 'type' => 'bool', 'internal' => 'hasPublicResult'],
'survey_template_start' => ['name' => 'survey_template_start', 'type' => 'DateTime', 'internal' => 'start'],
'survey_template_end' => ['name' => 'survey_template_end', 'type' => 'DateTime', 'internal' => 'end'],
'survey_template_virtual' => ['name' => 'survey_template_virtual', 'type' => 'string', 'internal' => 'virtualPath'],
'survey_template_created_by' => ['name' => 'survey_template_created_by', 'type' => 'int', 'internal' => 'createdBy'],
'survey_template_created_at' => ['name' => 'survey_template_created_at', 'type' => 'DateTimeImmutable', 'internal' => 'createdAt'],
];
/**
* Has many relation.
*
* @var array<string, array{mapper:string, table:string, self?:?string, external?:?string, column?:string}>
* @since 1.0.0
*/
protected static array $hasMany = [
'elements' => [
'mapper' => SurveyTemplateElementMapper::class,
'table' => 'survey_template_element',
'self' => 'survey_template_element_template',
'external' => null,
],
'l11n' => [
'mapper' => SurveyTemplateL11nMapper::class,
'table' => 'survey_template_l11n',
'self' => 'survey_template_l11n_template',
'conditional' => true,
'external' => null,
],
'tags' => [
'mapper' => TagMapper::class,
'table' => 'survey_template_tag',
'self' => 'survey_template_tag_dst',
'external' => 'survey_template_tag_src',
],
];
/**
* Belongs to.
*
* @var array<string, array{mapper:string, external:string}>
* @since 1.0.0
*/
protected static array $belongsTo = [
'createdBy' => [
'mapper' => AccountMapper::class,
'external' => 'survey_template_created_by',
],
];
/**
* Primary table.
*
* @var string
* @since 1.0.0
*/
protected static string $table = 'survey_template';
/**
* Created at.
*
* @var string
* @since 1.0.0
*/
protected static string $createdAt = 'survey_template_created_at';
/**
* Primary field name.
*
* @var string
* @since 1.0.0
*/
protected static string $primaryField = 'survey_template_id';
/**
* Get editor doc based on virtual path.
*
* @param string $virtualPath Virtual path
*
* @return array
*
* @since 1.0.0
*/
public static function getByVirtualPath(string $virtualPath = '/') : array
{
$depth = 2;
$query = self::getQuery(depth: $depth);
$query->where(self::$table . '_d' . $depth . '.survey_template_virtual', '=', $virtualPath);
return self::getAllByQuery($query, RelationType::ALL, $depth);
}
}

View File

@ -1,16 +0,0 @@
<?php
/**
* Orange Management
*
* PHP Version 7.4
*
* @package Modules\Surveys
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
$MODLANG[1] = [
];

32
Theme/Backend/styles.css Normal file
View File

@ -0,0 +1,32 @@
.survey .survey-description {
margin-bottom: 1rem; }
.survey .survey-value-element {
display: flex; }
.survey .survey-value-element .question-section {
flex: 1 1 0px; }
.survey .survey-value-element .question-section .question {
font-weight: bold;
padding-right: 3rem; }
.survey .survey-value-element .question-section .question-description {
padding-right: 3rem; }
.survey .survey-value-element .values-section {
flex: 1 1 0px; }
.survey .survey-value-element .values-section .labels, .survey .survey-value-element .values-section .values {
flex: 1 1 0px;
display: flex; }
.survey .survey-value-element .values-section .label {
flex: 1 1 0px;
text-align: center;
margin-bottom: 1rem; }
.survey .survey-value-element .values-section label {
justify-content: center; }
.survey .survey-value-element .values-section .value {
flex: 1 1 0px; }
.survey .survey-value-element + .survey-value-element {
margin-top: 1rem; }
.survey h1 {
margin: 1rem 0 1rem 0;
font-size: 1.3rem; }
.survey h2 {
margin: 0 0 1rem 0;
font-size: 1.1rem; }

60
Theme/Backend/styles.scss Normal file
View File

@ -0,0 +1,60 @@
.survey {
.survey-description {
margin-bottom: 1rem;
}
.survey-value-element {
display: flex;
.question-section {
flex: 1 1 0px;
.question {
font-weight: bold;
padding-right: 3rem;
}
.question-description {
padding-right: 3rem;
}
}
.values-section {
flex: 1 1 0px;
.labels, .values {
flex: 1 1 0px;
display: flex;
}
.label {
flex: 1 1 0px;
text-align: center;
margin-bottom: 1rem;
}
label {
justify-content: center;
}
.value {
flex: 1 1 0px;
}
}
}
.survey-value-element + .survey-value-element {
margin-top: 1rem;
}
h1 {
margin: 1rem 0 1rem 0;
font-size: 1.3rem;
}
h2 {
margin: 0 0 1rem 0;
font-size: 1.1rem;
}
}

View File

@ -12,75 +12,184 @@
*/
declare(strict_types=1);
use Modules\Surveys\Models\SurveyElementType;
/** @var null|Modules\Surveys\Models\SurveyTemplate $survey */
$survey = $this->getData('survey');
echo $this->getData('nav')->render(); ?>
<div class="row">
<div class="col-xs-12 col-md-6">
<section class="box wf-100">
<header><h1><?= $this->getHtml('Survey'); ?></h1></header>
<div class="inner">
<form>
<table class="layout wf-100">
<tr><td colspan="3"><label for="iName"><?= $this->getHtml('Name'); ?><label>
<tr><td colspan="2"><input type="text" id="iName" name="name" required><td>
<tr><td><label for="iStart"><?= $this->getHtml('Start'); ?><label><td><label for="iEnd"><?= $this->getHtml('End'); ?><label><td>
<tr><td><input type="datetime-local" id="iStart" name="start" required><td><input type="datetime-local" id="iEnd" name="end" required><td>
<tr><td colspan="3"><label for="iDesc"><?= $this->getHtml('Description'); ?><label>
<tr><td colspan="2"><textarea id="iDesc" name="desc"></textarea><td>
<tr><td colspan="3"><span class="check"><input type="checkbox" id="iResult" name="result"><label for="iResult"><?= $this->getHtml('ResultPublic'); ?><label></span>
<tr><td><label for="iResponsibility"><?= $this->getHtml('Responsibility'); ?><label><td colspan="2"><label for="iPerm"><?= $this->getHtml('UserGroup'); ?><label>
<tr><td><select id="iResponsibility" name="responsibility">
<option value=""><?= $this->getHtml('Questionee'); ?>
<option value=""><?= $this->getHtml('Manager'); ?>
</select><td><span class="input"><button type="button" formaction=""><i class="fa fa-book"></i></button><input type="text" id="iPerm" name="permission"></span><td><button><?= $this->getHtml('Add', '0', '0'); ?></button>
<tr><td colspan="3"><input type="submit" value="<?= $this->getHtml('Create', '0', '0'); ?>">
</table>
</form>
</div>
</section>
<div class="tabview tab-2">
<div class="box wf-100 col-xs-12">
<ul class="tab-links">
<li><label for="c-tab-1"><?= $this->getHtml('Survey'); ?></label>
<li><label for="c-tab-2"><?= $this->getHtml('Preview'); ?></label>
</ul>
</div>
<div class="tab-content">
<input type="radio" id="c-tab-1" name="tabular-2"<?= $this->request->uri->fragment === 'c-tab-1' ? ' checked' : ''; ?>>
<div class="tab">
<div class="row">
<div class="col-xs-12 col-md-6">
<section class="portlet">
<form>
<div class="portlet-head"><?= $this->getHtml('Survey'); ?></div>
<div class="portlet-body">
<table class="layout wf-100">
<tr><td colspan="3"><label for="iName"><?= $this->getHtml('Name'); ?><label>
<tr><td colspan="2"><input type="text" id="iName" name="name" required><td>
<tr><td><label for="iStart"><?= $this->getHtml('Start'); ?><label><td><label for="iEnd"><?= $this->getHtml('End'); ?><label><td>
<tr><td><input type="datetime-local" id="iStart" name="start" required><td><input type="datetime-local" id="iEnd" name="end" required><td>
<tr><td colspan="3"><label for="iDesc"><?= $this->getHtml('Description'); ?><label>
<tr><td colspan="2"><textarea id="iDesc" name="desc"></textarea><td>
<tr><td colspan="3">
<div class="input-control">
<label class="checkbox" for="iPublicResult">
<input id="iPublicResult" type="checkbox" name="public_result" value="1"<?= isset($survey) && $survey->hasPublicResult ? ' checked' : ''; ?>>
<span class="checkmark"></span>
<?= $this->getHtml('ResultPublic'); ?>
</label>
</div>
<tr><td><label for="iResponsibility"><?= $this->getHtml('Responsibility'); ?><label><td colspan="2"><label for="iPerm"><?= $this->getHtml('UserGroup'); ?><label>
<tr><td><select id="iResponsibility" name="responsibility">
<option value=""><?= $this->getHtml('Questionee'); ?>
<option value=""><?= $this->getHtml('Manager'); ?>
</select><td><span class="input"><button type="button" formaction=""><i class="fa fa-book"></i></button><input type="text" id="iPerm" name="permission"></span><td><button><?= $this->getHtml('Add', '0', '0'); ?></button>
</table>
</div>
<div class="portlet-foot">
<input type="submit" value="<?= $this->getHtml('Create', '0', '0'); ?>">
</div>
</form>
</section>
</div>
<div class="col-xs-12 col-md-6">
<section class="box wf-100">
<header><h1><?= $this->getHtml('Section'); ?></h1></header>
<div class="inner">
<form>
<table class="layout wf-100">
<tr><td colspan="2"><label for="iSection"><?= $this->getHtml('Section'); ?><label>
<tr><td colspan="2"><input type="text" id="iSection" name="section">
<tr><td colspan="2"><label for="iSDesc"><?= $this->getHtml('Description'); ?><label>
<tr><td colspan="2"><textarea id="iSDesc" name="sdesc"></textarea>
<tr><td colspan="2"><label for="iSType"><?= $this->getHtml('Type'); ?><label>
<tr><td colspan="2"><select id="iSType" name="stype">
<option>
</select>
<tr><td colspan="2"><input type="submit" value="<?= $this->getHtml('Add', '0', '0'); ?>">
</table>
</form>
</div>
</section>
</div>
</div>
<div class="row">
<div class="col-xs-12 col-md-6">
<section class="box wf-100">
<header><h1><?= $this->getHtml('Question'); ?></h1></header>
<div class="inner">
<form>
<table class="layout wf-100">
<tr><td colspan="2"><label for="iQuestion"><?= $this->getHtml('Question'); ?><label>
<tr><td colspan="2"><input type="text" id="iQuestion" name="question">
<tr><td colspan="2"><label for="iQDesc"><?= $this->getHtml('Description'); ?><label>
<tr><td colspan="2"><textarea id="iQDesc" name="qdesc"></textarea>
<tr><td colspan="2"><label for="iQSection"><?= $this->getHtml('Section'); ?><label>
<tr><td colspan="2"><select id="iQSection" name="iqsection">
<option>
<div class="col-xs-12 col-md-6">
<section class="box wf-100">
<header><h1><?= $this->getHtml('Element'); ?></h1></header>
<div class="inner">
<form>
<table class="layout wf-100">
<tr><td colspan="2"><label for="iSection"><?= $this->getHtml('Section'); ?><label>
<tr><td colspan="2"><input type="text" id="iSection" name="section">
<tr><td colspan="2"><label for="iSDesc"><?= $this->getHtml('Description'); ?><label>
<tr><td colspan="2"><textarea id="iSDesc" name="sdesc"></textarea>
<tr><td colspan="2"><label for="iSType"><?= $this->getHtml('Type'); ?><label>
<tr><td colspan="2"><select id="iSType" name="stype">
<option>
</select>
<tr><td colspan="2"><input type="submit" value="<?= $this->getHtml('Add', '0', '0'); ?>">
</table>
</form>
<tr><td colspan="2"><input type="submit" value="<?= $this->getHtml('Add', '0', '0'); ?>">
</table>
</form>
</div>
</section>
</div>
</div>
</section>
</div>
<input type="radio" id="c-tab-2" name="tabular-2"<?= $this->request->uri->fragment === 'c-tab-2' ? ' checked' : ''; ?>>
<div class="tab">
<div class="row">
<div class="col-xs-12">
<section class="portlet survey">
<form>
<div class="portlet-head"><?= $this->printHtml($survey->getL11n()->title); ?></div>
<div class="portlet-body">
<?php if (!empty($survey->getL11n()->description)) : ?>
<div class="survey-description"><?= $survey->getL11n()->description; ?></div>
<?php endif; ?>
<?php $elements = $survey->getElements();
foreach ($elements as $element) {
if ($element->type === SurveyElementType::HEADLINE) {
echo '<h1>' . $this->printHtml($element->getL11n()->text) . '</h1>';
echo !empty($element->getL11n()->description)
? '<h2>' . $element->getL11n()->description . '</h2>'
: '';
} elseif ($element->type === SurveyElementType::CHECKBOX
|| $element->type === SurveyElementType::RADIO
|| $element->type === SurveyElementType::DROPDOWN
|| $element->type === SurveyElementType::TEXTFIELD
|| $element->type === SurveyElementType::TEXTAREA
|| $element->type === SurveyElementType::NUMERIC
|| $element->type === SurveyElementType::DATE
) {
echo '<div class="survey-value-element">';
// Question/Text section
echo '<div class="question-section">';
echo '<div class="question">' . $this->printHtml($element->getL11n()->text) . '</div>';
echo !empty($element->getL11n()->description)
? '<div class="question-description">' . $element->getL11n()->description . '</div>'
: '';
echo '</div>';
// Value section
echo '<div class="values-section">';
if ($element->type === SurveyElementType::CHECKBOX
|| $element->type === SurveyElementType::RADIO
) :
$elementLabels = $element->getLabels();
if (($eCount = \count($elementLabels)) > 0) {
echo '<div class="labels">';
}
foreach ($elementLabels as $elementLabel) {
echo '<span class="label">' . $this->printHtml($elementLabel->title) . '</span>';
}
if ($eCount > 0) {
echo '</div>';
}
$elementValues = $element->getValues();
echo '<div class="values">';
foreach ($elementValues as $elementValue) :
if ($element->type === SurveyElementType::CHECKBOX) : ?>
<div class="input-control value">
<label class="checkbox" for="i<?= $element->getId() . '-' . $this->printHtml($elementValue); ?>">
<input id="i<?= $element->getId() . '-' . $this->printHtml($elementValue); ?>" type="checkbox" name="i<?= $element->getId() . '-' . $this->printHtml($elementValue); ?>" value="1">
<span class="checkmark"></span>
</label>
</div>
<?php elseif ($element->type === SurveyElementType::RADIO) : ?>
<div class="input-control value">
<label class="radio" for="i<?= $element->getId() . '-' . $this->printHtml($elementValue); ?>">
<input id="i<?= $element->getId() . '-' . $this->printHtml($elementValue); ?>" type="radio" name="i<?= $element->getId(); ?>" value="<?= $this->printHtml($elementValue); ?>"<?= isset($survey) && $survey->hasPublicResult ? '' : ''; ?>>
<span class="checkmark"></span>
</label>
</div>
<?php endif; endforeach;
echo '</div>'; // closing "values"
elseif ($element->type === SurveyElementType::DROPDOWN) :
$elementValues = $element->getValues();
echo '<select>';
$elementLabels = \array_values($element->getLabels());
foreach ($elementValues as $key => $elementValue) : ?>
<option value="<?= $this->printHtml($elementValue); ?>"><?= $this->printHtml($elementLabels[$key]->title); ?>
<?php endforeach;
echo '</select>';
elseif ($element->type === SurveyElementType::TEXTFIELD) : ?>
<input type="text">
<?php elseif ($element->type === SurveyElementType::TEXTAREA) : ?>
<textarea></textarea>
<?php elseif ($element->type === SurveyElementType::NUMERIC) : ?>
<input type="number">
<?php elseif ($element->type === SurveyElementType::DATE) : ?>
<input type="datetime-local">
<?php endif;
echo '</div>'; // closing "values-section"
echo '</div>'; // closing "survey-value-element"
}
} ?>
</div>
<div class="portlet-foot">
<input type="submit" value="<?= $this->getHtml('Create', '0', '0'); ?>">
</div>
</form>
</section>
</div>
</div>
</div>
</div>
</div>

View File

@ -12,35 +12,170 @@
*/
declare(strict_types=1);
use phpOMS\Uri\UriFactory;
$footerView = new \phpOMS\Views\PaginationView($this->l11nManager, $this->request, $this->response);
$footerView->setTemplate('/Web/Templates/Lists/Footer/PaginationBig');
$footerView->setPages(20);
$footerView->setPage(1);
/**
* @var \phpOMS\Views\View $this
* @var \Modules\Surveys\Models\Survey[] $surveys
*/
$surveys = $this->getData('surveys') ?? [];
/** @var \Modules\Admin\Models\Account $account */
$account = $this->getData('account');
$accountDir = $account->getId() . ' ' . $account->login;
/** @var \Modules\Media\Models\Collection[] */
$collections = $this->getData('collections');
$mediaPath = \urldecode($this->getData('path') ?? '/');
$previous = empty($surveys) ? '{/prefix}survey/list' : '{/prefix}survey/list?{?}&id=' . \reset($surveys)->getId() . '&ptype=p';
$next = empty($surveys) ? '{/prefix}survey/list' : '{/prefix}survey/list?{?}&id=' . \end($surveys)->getId() . '&ptype=n';
echo $this->getData('nav')->render(); ?>
<div class="row">
<div class="col-xs-12">
<div class="box wf-100">
<table class="default">
<caption><?= $this->getHtml('Surveys'); ?><i class="fa fa-download floatRight download btn"></i></caption>
<div class="box">
<ul class="crumbs-2">
<li data-href="<?= UriFactory::build('{/prefix}survey/list?path=/Accounts/' . $accountDir); ?>"><a href="<?= UriFactory::build('{/prefix}survey/list?path=/Accounts/' . $accountDir); ?>"><i class="fa fa-home"></i></a>
<li data-href="<?= UriFactory::build('{/prefix}survey/list?path=/'); ?>"><a href="<?= UriFactory::build('{/prefix}survey/list?path=/'); ?>">/</a></li>
<?php
$subPath = '';
$paths = \explode('/', \ltrim($mediaPath, '/'));
$length = \count($paths);
$parentPath = '';
for ($i = 0; $i < $length; ++$i) :
if ($paths[$i] === '') {
continue;
}
if ($i === $length - 1) {
$parentPath = $subPath === '' ? '/' : $subPath;
}
$subPath .= '/' . $paths[$i];
$url = UriFactory::build('{/prefix}survey/list?path=' . $subPath);
?>
<li data-href="<?= $url; ?>"<?= $i === $length - 1 ? 'class="active"' : ''; ?>><a href="<?= $url; ?>"><?= $this->printHtml($paths[$i]); ?></a></li>
<?php endfor; ?>
</ul>
</div>
</div>
</div>
<div class="row">
<div class="col-xs-12">
<div class="portlet">
<div class="portlet-head"><?= $this->getHtml('Surveys'); ?><i class="fa fa-download floatRight download btn"></i></div>
<table id="surveyList" class="default sticky">
<thead>
<tr>
<td><?= $this->getHtml('Status') ?>
<td class="wf-100"><?= $this->getHtml('Title') ?>
<td><?= $this->getHtml('Created') ?>
<td><?= $this->getHtml('Creator') ?>
<tfoot>
<tr>
<td colspan="4">
<td><label class="checkbox" for="surveyList-0">
<input type="checkbox" id="surveyList-0" name="surveyselect">
<span class="checkmark"></span>
</label>
<td>
<td class="wf-100"><?= $this->getHtml('Name'); ?>
<label for="surveyList-sort-1">
<input type="radio" name="surveyList-sort" id="surveyList-sort-1">
<i class="sort-asc fa fa-chevron-up"></i>
</label>
<label for="surveyList-sort-2">
<input type="radio" name="surveyList-sort" id="surveyList-sort-2">
<i class="sort-desc fa fa-chevron-down"></i>
</label>
<label>
<i class="filter fa fa-filter"></i>
</label>
<td><?= $this->getHtml('Tag'); ?>
<label for="surveyList-sort-3">
<input type="radio" name="surveyList-sort" id="surveyList-sort-3">
<i class="sort-asc fa fa-chevron-up"></i>
</label>
<label for="surveyList-sort-4">
<input type="radio" name="surveyList-sort" id="surveyList-sort-4">
<i class="sort-desc fa fa-chevron-down"></i>
</label>
<label>
<i class="filter fa fa-filter"></i>
</label>
<td><?= $this->getHtml('Creator'); ?>
<label for="surveyList-sort-5">
<input type="radio" name="surveyList-sort" id="surveyList-sort-5">
<i class="sort-asc fa fa-chevron-up"></i>
</label>
<label for="surveyList-sort-6">
<input type="radio" name="surveyList-sort" id="surveyList-sort-6">
<i class="sort-desc fa fa-chevron-down"></i>
</label>
<label>
<i class="filter fa fa-filter"></i>
</label>
<td><?= $this->getHtml('Created'); ?>
<label for="surveyList-sort-7">
<input type="radio" name="surveyList-sort" id="surveyList-sort-7">
<i class="sort-asc fa fa-chevron-up"></i>
</label>
<label for="surveyList-sort-8">
<input type="radio" name="surveyList-sort" id="surveyList-sort-8">
<i class="sort-desc fa fa-chevron-down"></i>
</label>
<label>
<i class="filter fa fa-filter"></i>
</label>
<tbody>
<?php $count = 0; foreach ([] as $key => $value) : ++$count; ?>
<?php if (!empty($parentPath)) : $url = UriFactory::build('{/prefix}survey/list?path=' . $parentPath); ?>
<tr tabindex="0" data-href="<?= $url; ?>">
<td>
<td data-label="<?= $this->getHtml('Type'); ?>"><a href="<?= $url; ?>"><i class="fa fa-folder-open-o"></i></a>
<td data-label="<?= $this->getHtml('Name'); ?>"><a href="<?= $url; ?>">..
</a>
<td>
<td>
<td>
<td>
<?php endif; ?>
<?php $count = 0; foreach ($collections as $key => $value) : ++$count;
$url = UriFactory::build('{/prefix}survey/list?path=' . \rtrim($value->getVirtualPath(), '/') . '/' . $value->name);
?>
<tr data-href="<?= $url; ?>">
<td><label class="checkbox" for="surveyList-<?= $key; ?>">
<input type="checkbox" id="surveyList-<?= $key; ?>" name="surveyselect">
<span class="checkmark"></span>
</label>
<td><a href="<?= $url; ?>"><i class="fa fa-folder-open-o"></i></a>
<td><a href="<?= $url; ?>"><?= $this->printHtml($value->name); ?></a>
<td>
<td><a class="content" href="<?= UriFactory::build('{/prefix}profile/single?{?}&for=' . $value->createdBy->getId()); ?>"><?= $this->printHtml($value->createdBy->name1); ?></a>
<td><a href="<?= $url; ?>"><?= $this->printHtml($value->createdAt->format('Y-m-d')); ?></a>
<?php endforeach; ?>
<?php
$count = 0;
foreach ($surveys as $key => $value) : ++$count;
$url = UriFactory::build('{/prefix}survey/edit?{?}&id=' . $value->getId()); ?>
?>
<tr data-href="<?= $url; ?>">
<td><label class="checkbox" for="surveyList-<?= $key; ?>">
<input type="checkbox" id="surveyList-<?= $key; ?>" name="surveyselect">
<span class="checkmark"></span>
</label>
<td>
<td><a href="<?= $url; ?>"><?= $value->getL11n()->title; ?></a>
<td>
<td><a class="content" href="<?= UriFactory::build('{/prefix}profile/single?{?}&for=' . $value->createdBy->getId()); ?>"><?= $value->createdBy->name1; ?></a>
<td><a href="<?= $url; ?>"><?= $value->createdAt->format('Y-m-d'); ?></a>
<?php endforeach; ?>
<?php if ($count === 0) : ?>
<tr><td colspan="4" class="empty"><?= $this->getHtml('Empty', '0', '0'); ?>
<tr><td colspan="6" class="empty"><?= $this->getHtml('Empty', '0', '0'); ?>
<?php endif; ?>
</table>
<div class="portlet-foot">
<a tabindex="0" class="button" href="<?= UriFactory::build($previous); ?>"><?= $this->getHtml('Previous', '0', '0'); ?></a>
<a tabindex="0" class="button" href="<?= UriFactory::build($next); ?>"><?= $this->getHtml('Next', '0', '0'); ?></a>
</div>
</div>
</div>
</div>

View File

@ -1,15 +0,0 @@
<?php
/**
* Orange Management
*
* PHP Version 7.4
*
* @package Modules\Surveys
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
echo $this->getData('nav')->render();

View File

@ -18,6 +18,7 @@
"directory": "Surveys",
"dependencies": {
"Admin": "1.0.0",
"Tag": "1.0.0",
"Tools": "1.0.0"
},
"providing": {