| Current Path : /var/www/v3.cesa.co.za/src/ContentBundle/Entity/ |
| Current File : /var/www/v3.cesa.co.za/src/ContentBundle/Entity/FormItem.php |
<?php
namespace App\ContentBundle\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
/**
* FormItem
*
* @ORM\Table(name="content_form_item")
* @ORM\Entity(repositoryClass="App\ContentBundle\Repository\FormItemRepository")
* @ORM\HasLifecycleCallbacks
*/
class FormItem
{
/**
* @ORM\Id
* @ORM\Column(type="string", unique=true)
* @ORM\GeneratedValue(strategy="CUSTOM")
* @ORM\CustomIdGenerator(class="Ramsey\Uuid\Doctrine\UuidGenerator")
*/
private $id;
/**
* @ORM\Column(type="string", length=10, nullable=true)
*/
private $date_col;
/**
* @ORM\Column(type="string", length=10, nullable=true)
*/
private $time_col;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $prompt;
/**
* @ORM\Column(type="string", length=100, nullable=true)
*/
private $presenter_name;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $description;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $sentence_part;
/**
* @ORM\Column(type="blob", nullable=true)
*/
private $default_value;
/**
* @ORM\Column(type="boolean", nullable=true, options={"default": false})
*/
private $is_required;
/**
* @ORM\Column(type="integer", nullable=true, options={"default": 0})
*/
private $max_value;
/**
* @ORM\Column(type="integer", nullable=true, options={"default": 0})
*/
private $min_value;
/**
* @ORM\Column(type="boolean", nullable=true, options={"default": false})
*/
private $is_active;
/**
* @ORM\Column(type="boolean", nullable=true, options={"default": false})
*/
private $is_deleted;
/**
* @ORM\Column(type="boolean", nullable=true, options={"default": false})
*/
private $additional_comments;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $created_by;
/**
* @ORM\Column(type="datetime")
*/
private $created_at;
/**
* @ORM\Column(type="datetime")
*/
private $updated_at;
/**
* @ORM\OneToMany(targetEntity="FormItemForm", mappedBy="form_item", cascade={"persist", "remove"})
*/
private $forms;
/**
* @ORM\OneToMany(targetEntity="FormItemList", mappedBy="form_item", cascade={"persist", "remove"})
*/
private $form_item_list;
/**
* @ORM\OneToMany(targetEntity="FormItemCompleted", mappedBy="form_item", cascade={"persist", "remove"})
*/
private $form_item_completed;
/**
* @ORM\ManyToOne(targetEntity="FormItemType")
* @ORM\JoinColumn(name="form_item_type_id", referencedColumnName="id")
*/
private $form_item_type;
public function __construct()
{
$this->forms = new ArrayCollection();
$this->form_item_list = new ArrayCollection();
$this->form_item_completed = new ArrayCollection();
}
public function getId(): ?string
{
return $this->id;
}
public function getPrompt(): ?string
{
return $this->prompt;
}
public function setPrompt(?string $prompt): static
{
$this->prompt = $prompt;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): static
{
$this->description = $description;
return $this;
}
public function getSentencePart(): ?string
{
return $this->sentence_part;
}
public function setSentencePart(?string $sentence_part): static
{
$this->sentence_part = $sentence_part;
return $this;
}
public function getDefaultValue()
{
return $this->default_value;
}
public function setDefaultValue($default_value): static
{
$this->default_value = $default_value;
return $this;
}
public function isIsRequired(): ?bool
{
return $this->is_required;
}
public function setIsRequired(?bool $is_required): static
{
$this->is_required = $is_required;
return $this;
}
public function getMaxValue(): ?int
{
return $this->max_value;
}
public function setMaxValue(?int $max_value): static
{
$this->max_value = $max_value;
return $this;
}
public function getMinValue(): ?int
{
return $this->min_value;
}
public function setMinValue(?int $min_value): static
{
$this->min_value = $min_value;
return $this;
}
public function isIsActive(): ?bool
{
return $this->is_active;
}
public function setIsActive(?bool $is_active): static
{
$this->is_active = $is_active;
return $this;
}
public function isIsDeleted(): ?bool
{
return $this->is_deleted;
}
public function setIsDeleted(?bool $is_deleted): static
{
$this->is_deleted = $is_deleted;
return $this;
}
public function isAdditionalComments(): ?bool
{
return $this->additional_comments;
}
public function setAdditionalComments(?bool $additional_comments): static
{
$this->additional_comments = $additional_comments;
return $this;
}
public function getCreatedBy(): ?string
{
return $this->created_by;
}
public function setCreatedBy(?string $created_by): static
{
$this->created_by = $created_by;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->created_at;
}
public function setCreatedAt(\DateTimeInterface $created_at): static
{
$this->created_at = $created_at;
return $this;
}
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updated_at;
}
public function setUpdatedAt(\DateTimeInterface $updated_at): static
{
$this->updated_at = $updated_at;
return $this;
}
/**
* @return Collection<int, FormItemForm>
*/
public function getForms(): Collection
{
return $this->forms;
}
public function addForm(FormItemForm $form): static
{
if (!$this->forms->contains($form)) {
$this->forms->add($form);
$form->setFormItem($this);
}
return $this;
}
public function removeForm(FormItemForm $form): static
{
if ($this->forms->removeElement($form)) {
// set the owning side to null (unless already changed)
if ($form->getFormItem() === $this) {
$form->setFormItem(null);
}
}
return $this;
}
/**
* @return Collection<int, FormItemList>
*/
public function getFormItemList(): Collection
{
return $this->form_item_list;
}
public function addFormItemList(FormItemList $formItemList): static
{
if (!$this->form_item_list->contains($formItemList)) {
$this->form_item_list->add($formItemList);
$formItemList->setFormItem($this);
}
return $this;
}
public function removeFormItemList(FormItemList $formItemList): static
{
if ($this->form_item_list->removeElement($formItemList)) {
// set the owning side to null (unless already changed)
if ($formItemList->getFormItem() === $this) {
$formItemList->setFormItem(null);
}
}
return $this;
}
/**
* @return Collection<int, FormItemCompleted>
*/
public function getFormItemCompleted(): Collection
{
return $this->form_item_completed;
}
public function addFormItemCompleted(FormItemCompleted $formItemCompleted): static
{
if (!$this->form_item_completed->contains($formItemCompleted)) {
$this->form_item_completed->add($formItemCompleted);
$formItemCompleted->setFormItem($this);
}
return $this;
}
public function removeFormItemCompleted(FormItemCompleted $formItemCompleted): static
{
if ($this->form_item_completed->removeElement($formItemCompleted)) {
// set the owning side to null (unless already changed)
if ($formItemCompleted->getFormItem() === $this) {
$formItemCompleted->setFormItem(null);
}
}
return $this;
}
public function getFormItemType(): ?FormItemType
{
return $this->form_item_type;
}
public function setFormItemType(?FormItemType $form_item_type): static
{
$this->form_item_type = $form_item_type;
return $this;
}
/**
* @ORM\PrePersist
*/
public function setCreatedAtValue()
{
if (is_null($this->getCreatedAt())) {
$this->setCreatedAt(new \DateTime());
}
if (is_null($this->getUpdatedAt())) {
$this->setUpdatedAt(new \DateTime());
}
}
/**
* @ORM\PreUpdate
*/
public function setUpdatedAtValue()
{
$this->setUpdatedAt(new \DateTime());
}
/**
* get order by
*
* @param Form $form
*/
public function getOrderBy(Form $form)
{
$return = 0;
$formItemForms = $this->getForms();
foreach ($formItemForms as $formItemForm) {
if ($formItemForm->getForm()->getId() == $form->getId()) {
$return = $formItemForm->getOrderBy();
}
}
return $return;
}
/**
* get object as array
*
* @param Form $form
*/
public function getAsArray(Form $form)
{
$return = array(
'id' => $this->getId(),
'form_item_type' => $this->getFormItemType()->getId(),
'form_item_type_name' => $this->getFormItemType()->getTypeName(),
'form_item_type' => $this->getFormItemType()->getArray(),
'date_col' => $this->getDateCol(),
'time_col' => $this->getTimeCol(),
'prompt' => $this->getPrompt(),
'presenter_name' => $this->getPresenterName(),
'description' => $this->getDescription(),
'sentence_part' => $this->getSentencePart(),
'default_value' => $this->getDefaultValue(),
'is_required' => $this->isIsRequired(),
'min_value' => $this->getMinValue(),
'max_value' => $this->getMaxValue(),
'select_list_options' => $this->getSelectListOptions(),
'order_by' => $this->getOrderBy($form),
'widget_id' => $form->getId() . '-' . $this->getId(),
'widget_name' => $this->getFormItemType()->getWidgetName(),
'additional_comments' => $this->isAdditionalComments(),
);
$return['json_string'] = json_encode($return);
return $return;
}
/**
* get object as JSON string
*
* @param Form $form
*/
public function getJSonString(Form $form)
{
$objectArray = $this->getAsArray($form);
return $objectArray['json_string'];
}
/**
* get options as a list
*
* @return string
*/
public function getSelectListOptions()
{
$return = '';
$options = $this->getFormItemList();
if (!is_countable($options) || count($options) <= 0) {
$options = array();
if ($this->getFormItemType()->getWidgetName() == 'helpful') {
$options = array(
'Extremely Helpful' => 'Extremely Helpful',
'Very Helpful' => 'Very Helpful',
'Somewhat Helpful' => 'Somewhat Helpful',
'Not Helpful' => 'Not Helpful',
);
return $options;
}
if ($this->getFormItemType()->getWidgetName() == 'keep_drop') {
$options = array(
'Definitely Keep on BCE' => 'Definitely Keep on BCE',
'Possibly Keep on BCE' => 'Possibly Keep on BCE',
'Drop from BCE' => 'Drop from BCE',
);
return $options;
}
if ($this->getFormItemType()->getWidgetName() == 'excellent_satisfactory') {
$options = array(
'Excellent' => 'Excellent',
'Very Good' => 'Very Good',
'Average' => 'Average',
'Satisfactory' => 'Satisfactory',
);
return $options;
}
if ($this->getFormItemType()->getWidgetName() == 'excellent_good') {
$options = array(
'Excellent' => 'Excellent',
'Very Good' => 'Very Good',
'Good' => 'Good',
);
return $options;
}
if ($this->getFormItemType()->getWidgetName() == 'excellent_poor') {
$options = array(
'Excellent' => 'Excellent',
'Very Good' => 'Very Good',
'Good' => 'Good',
'Fair' => 'Fair',
'Poor' => 'Poor',
);
return $options;
}
if ($this->getFormItemType()->getWidgetName() == 'expectations') {
$options = array(
'Surpassed Expectations' => 'Surpassed Expectations',
'Met my Expectation' => 'Met my Expectation',
'Not at All' => 'Not at All',
);
return $options;
}
if ($this->getFormItemType()->getWidgetName() == 'substantially') {
$options = array(
'Substantially' => 'Substantially',
'Somewhat' => 'Somewhat',
'Not at All' => 'Not at All',
);
return $options;
}
if ($this->getFormItemType()->getWidgetName() == 'agree_na') {
$options = array(
'Strongly Agree' => 'Strongly Agree',
'Agree' => 'Agree',
'Disagree' => 'Disagree',
'Strongly Disagree' => 'Strongly Disagree',
// 'N/A' => 'N/A',
);
return $options;
}
if ($this->getFormItemType()->getWidgetName() == 'bce_modules') {
$options = array(
'CEE' => 'CEE',
'Project Delivery' => 'Project Delivery',
'Law' => 'Law',
'Finance' => 'Finance',
'Interpersonal Skills' => 'Interpersonal Skills',
);
return $options;
}
if ($this->getFormItemType()->getWidgetName() == 'yes_somewhat_no') {
$options = array(
'Yes' => 'Yes',
'Somewhat' => 'Somewhat',
'No' => 'No',
);
return $options;
}
if ($this->getFormItemType()->getWidgetName() == 'time_spent_compiling') {
$options = array(
'1 to 4' => '1 to 4',
'4 to 8' => '4 to 8',
'8 to 12' => '8 to 12',
'over 12' => 'over 12',
);
return $options;
}
}
$count = 1;
for ($cnt = 0; $cnt < (count($options) - 1); $cnt++) {
for ($cnt2 = $cnt; $cnt2 < count($options); $cnt2++) {
if ($options[$cnt2]->getOrderBy() < $options[$cnt]->getOrderBy()) {
$dummy = $options[$cnt];
$options[$cnt] = $options[$cnt2];
$options[$cnt2] = $dummy;
}
}
}
foreach ($options as $option) {
$return .= $option->getListItem();
if ($count < count($options)) {
$return .= "\n";
}
$count++;
}
return $return;
}
/**
* Get object as string
*/
public function __toString()
{
return (string) $this->getPrompt();
}
public function getDateCol(): ?string
{
return $this->date_col;
}
public function setDateCol(?string $date_col): static
{
$this->date_col = $date_col;
return $this;
}
public function getPresenterName(): ?string
{
return $this->presenter_name;
}
public function setPresenterName(?string $presenter_name): static
{
$this->presenter_name = $presenter_name;
return $this;
}
public function getTimeCol(): ?string
{
return $this->time_col;
}
public function setTimeCol(?string $time_col): static
{
$this->time_col = $time_col;
return $this;
}
public function isRequired(): ?bool
{
return $this->is_required;
}
public function isActive(): ?bool
{
return $this->is_active;
}
public function isDeleted(): ?bool
{
return $this->is_deleted;
}
}