modules/QSL/CustomerSatisfaction/src/Model/Survey.php line 29

Open in your IDE?
  1. <?php
  2. /**
  3.  * Copyright (c) 2011-present Qualiteam software Ltd. All rights reserved.
  4.  * See https://www.x-cart.com/license-agreement.html for license details.
  5.  */
  6. namespace QSL\CustomerSatisfaction\Model;
  7. use Doctrine\ORM\Mapping as ORM;
  8. /**
  9.  * Survey
  10.  *
  11.  * @ORM\Entity (repositoryClass="\QSL\CustomerSatisfaction\Model\Repo\Survey")
  12.  *
  13.  * @ORM\Table  (name="surveys",
  14.  *      uniqueConstraints={
  15.  *          @ORM\UniqueConstraint (name="pair", columns={"id","order_id"})
  16.  *      },
  17.  *      indexes={
  18.  *          @ORM\Index (name="status",     columns={"status"}),
  19.  *          @ORM\Index (name="customer",   columns={"customer_id"}),
  20.  *          @ORM\Index (name="emailDate", columns={"emailDate"}),
  21.  *          @ORM\Index (name="rating",     columns={"rating"})
  22.  *      }
  23.  * )
  24.  */
  25. class Survey extends \XLite\Model\AEntity
  26. {
  27.     public const STATUS_HIDDEN      'H';
  28.     public const STATUS_NEW         'N';
  29.     public const STATUS_IN_PROGRESS 'P';
  30.     public const STATUS_CLOSED      'C';
  31.     /**
  32.      * Survey statuses labels
  33.      *
  34.      * @var array
  35.      */
  36.     protected $surveyStatuses = [
  37.         \QSL\CustomerSatisfaction\Model\Survey::STATUS_NEW         => 'New',
  38.         \QSL\CustomerSatisfaction\Model\Survey::STATUS_IN_PROGRESS => 'In progress',
  39.         \QSL\CustomerSatisfaction\Model\Survey::STATUS_CLOSED      => 'Closed',
  40.     ];
  41.     /**
  42.      * Unique survey ID
  43.      *
  44.      * @var mixed
  45.      *
  46.      * @ORM\Id
  47.      * @ORM\GeneratedValue (strategy="AUTO")
  48.      * @ORM\Column         (type="integer")
  49.      */
  50.     protected $id;
  51.     /**
  52.      * Survey Order ID
  53.      *
  54.      * @var \XLite\Model\Order
  55.      *
  56.      * @ORM\OneToOne (targetEntity="XLite\Model\Order", inversedBy="survey")
  57.      * @ORM\JoinColumn (name="order_id", referencedColumnName="order_id", onDelete="CASCADE")
  58.      */
  59.     protected $order;
  60.     /**
  61.      * Survey rating
  62.      *
  63.      * @var integer
  64.      *
  65.      * @ORM\Column (type="integer", nullable=true)
  66.      */
  67.     protected $rating;
  68.     /**
  69.      * Survey processing status
  70.      *
  71.      * @var string
  72.      *
  73.      * @ORM\Column (type="string", options={ "fixed": true }, length=1)
  74.      */
  75.     protected $status \QSL\CustomerSatisfaction\Model\Survey::STATUS_HIDDEN;
  76.     /**
  77.      * Survey email sent date
  78.      *
  79.      * @var integer
  80.      *
  81.      * @ORM\Column (type="integer", nullable=true)
  82.      */
  83.     protected $emailDate;
  84.     /**
  85.      * Survey init date
  86.      *
  87.      * @var integer
  88.      *
  89.      * @ORM\Column (type="integer", nullable=true)
  90.      */
  91.     protected $initDate;
  92.     /**
  93.      * Survey feedback received date
  94.      *
  95.      * @var integer
  96.      *
  97.      * @ORM\Column (type="integer", nullable=true)
  98.      */
  99.     protected $feedbackDate;
  100.     /**
  101.      * Survey feedback processed date
  102.      *
  103.      * @var integer
  104.      *
  105.      * @ORM\Column (type="integer", nullable=true)
  106.      */
  107.     protected $feedbackProcessedDate;
  108.     /**
  109.      * Survey comments
  110.      *
  111.      * @var string
  112.      *
  113.      * @ORM\Column (type="text")
  114.      */
  115.     protected $comments '';
  116.     /**
  117.      * Survey comments
  118.      *
  119.      * @var string
  120.      *
  121.      * @ORM\Column (type="text")
  122.      */
  123.     protected $customerMessage '';
  124.     /**
  125.      * Survey assigned manager
  126.      *
  127.      * @var \XLite\Model\Profile
  128.      *
  129.      * @ORM\ManyToOne (targetEntity="XLite\Model\Profile", inversedBy="managerSurveys", cascade={"merge","detach"})
  130.      * @ORM\JoinColumn (name="manager_id", referencedColumnName="profile_id")
  131.      */
  132.     protected $manager;
  133.     /**
  134.      * Survey customer
  135.      *
  136.      * @var \XLite\Model\Profile
  137.      *
  138.      * @ORM\ManyToOne (targetEntity="XLite\Model\Profile", inversedBy="customerSurveys", cascade={"merge","detach"})
  139.      * @ORM\JoinColumn (name="customer_id", referencedColumnName="profile_id")
  140.      */
  141.     protected $customer;
  142.     /**
  143.      * Relations to a Answer entities
  144.      *
  145.      * @var \Doctrine\Common\Collections\Collection
  146.      *
  147.      * @ORM\OneToMany (targetEntity="QSL\CustomerSatisfaction\Model\Answer", mappedBy="survey", cascade={"all"})
  148.      */
  149.     protected $answers;
  150.     /**
  151.      * Relation to a TagSurvey entities
  152.      *
  153.      * @var \QSL\CustomerSatisfaction\Model\Tag
  154.      *
  155.      * @ORM\ManyToMany (targetEntity="QSL\CustomerSatisfaction\Model\Tag", mappedBy="surveys", cascade={"all"})    *
  156.      */
  157.     protected $tags;
  158.     /**
  159.      * Hash key
  160.      *
  161.      * @var string
  162.      *
  163.      * @ORM\Column (type="string", length=128, unique=true, nullable=true)
  164.      */
  165.     protected $hashKey;
  166.     /**
  167.      * Question is enabled
  168.      *
  169.      * @var boolean
  170.      *
  171.      * @ORM\Column (type="boolean")
  172.      */
  173.     protected $filled false;
  174.     /**
  175.      * Prepare creation date
  176.      *
  177.      * @return void
  178.      *
  179.      * @ORM\PrePersist
  180.      */
  181.     public function prepareBeforeCreate()
  182.     {
  183.         if (!$this->getInitDate()) {
  184.             $this->setInitDate(\XLite\Core\Converter::time());
  185.         }
  186.     }
  187.     /**
  188.      * Return status string
  189.      *
  190.      * @return string
  191.      *
  192.      */
  193.     public function getStatusString()
  194.     {
  195.         $statuses $this->getSurveyStatuses();
  196.         return $statuses[$this->getStatus()];
  197.     }
  198.     /**
  199.      * Return tags in one string
  200.      *
  201.      * @return string
  202.      *
  203.      */
  204.     public function getTagsString()
  205.     {
  206.         $tags $this->tags;
  207.         $returnTags = [];
  208.         foreach ($tags as $tag) {
  209.             $returnTags[] = $tag->getName();
  210.         }
  211.         if ($returnTags) {
  212.             $tagsString implode(','$returnTags);
  213.         }
  214.         return (!empty($tagsString)) ? $tagsString '';
  215.     }
  216.     /**
  217.      * Return survey statuses
  218.      *
  219.      * @return array
  220.      *
  221.      */
  222.     public static function getSurveyStatuses()
  223.     {
  224.         return [
  225.            \QSL\CustomerSatisfaction\Model\Survey::STATUS_NEW          => 'New',
  226.             \QSL\CustomerSatisfaction\Model\Survey::STATUS_IN_PROGRESS => 'In progress',
  227.             \QSL\CustomerSatisfaction\Model\Survey::STATUS_CLOSED      => 'Closed',
  228.         ];
  229.     }
  230.     /**
  231.      * Sets the Survey statuses labels.
  232.      *
  233.      * @param array $surveyStatuses the survey statuses
  234.      *
  235.      * @return self
  236.      */
  237.     public function setSurveyStatuses(array $surveyStatuses)
  238.     {
  239.         $this->surveyStatuses $surveyStatuses;
  240.     }
  241.     /**
  242.      * Gets the Unique survey ID.
  243.      *
  244.      * @return mixed
  245.      */
  246.     public function getId()
  247.     {
  248.         return $this->id;
  249.     }
  250.     /**
  251.      * Sets the Unique survey ID.
  252.      *
  253.      * @param mixed $id the id
  254.      *
  255.      * @return self
  256.      */
  257.     public function setId($id)
  258.     {
  259.         $this->id $id;
  260.     }
  261.     /**
  262.      * Gets the Survey Order ID.
  263.      *
  264.      * @return \XLite\Model\Order
  265.      */
  266.     public function getOrder()
  267.     {
  268.         return $this->order;
  269.     }
  270.     /**
  271.      * Sets the Survey Order ID.
  272.      *
  273.      * @param \XLite\Model\Order $order the order
  274.      *
  275.      * @return self
  276.      */
  277.     public function setOrder($order)
  278.     {
  279.         $this->order $order;
  280.     }
  281.     /**
  282.      * Gets the Survey rating.
  283.      *
  284.      * @return integer
  285.      */
  286.     public function getRating()
  287.     {
  288.         return $this->rating;
  289.     }
  290.     /**
  291.      * Sets the Survey rating.
  292.      *
  293.      * @param integer $rating the rating
  294.      *
  295.      * @return self
  296.      */
  297.     public function setRating($rating)
  298.     {
  299.         $this->rating $rating;
  300.     }
  301.     /**
  302.      * Gets the Survey processing status.
  303.      *
  304.      * @return string
  305.      */
  306.     public function getStatus()
  307.     {
  308.         return $this->status;
  309.     }
  310.     /**
  311.      * Sets the Survey processing status.
  312.      *
  313.      * @param string $status the status
  314.      *
  315.      * @return self
  316.      */
  317.     public function setStatus($status)
  318.     {
  319.         $this->status $status;
  320.     }
  321.     /**
  322.      * Gets the Survey email sent date.
  323.      *
  324.      * @return integer
  325.      */
  326.     public function getEmailDate()
  327.     {
  328.         return $this->emailDate;
  329.     }
  330.     /**
  331.      * Sets the Survey email sent date.
  332.      *
  333.      * @param integer $emailDate the email date
  334.      *
  335.      * @return self
  336.      */
  337.     public function setEmailDate($emailDate)
  338.     {
  339.         $this->emailDate $emailDate;
  340.     }
  341.     /**
  342.      * Gets the Survey init date.
  343.      *
  344.      * @return integer
  345.      */
  346.     public function getInitDate()
  347.     {
  348.         return $this->initDate;
  349.     }
  350.     /**
  351.      * Sets the Survey init date.
  352.      *
  353.      * @param integer $initDate the init date
  354.      *
  355.      * @return self
  356.      */
  357.     public function setInitDate($initDate)
  358.     {
  359.         $this->initDate $initDate;
  360.     }
  361.     /**
  362.      * Gets the Survey feedback received date.
  363.      *
  364.      * @return integer
  365.      */
  366.     public function getFeedbackDate()
  367.     {
  368.         return $this->feedbackDate;
  369.     }
  370.     /**
  371.      * Sets the Survey feedback received date.
  372.      *
  373.      * @param integer $feedbackDate the feedback date
  374.      *
  375.      * @return self
  376.      */
  377.     public function setFeedbackDate($feedbackDate)
  378.     {
  379.         $this->feedbackDate $feedbackDate;
  380.     }
  381.     /**
  382.      * Gets the Survey feedback processed date.
  383.      *
  384.      * @return integer
  385.      */
  386.     public function getFeedbackProcessedDate()
  387.     {
  388.         return $this->feedbackProcessedDate;
  389.     }
  390.     /**
  391.      * Sets the Survey feedback processed date.
  392.      *
  393.      * @param integer $feedbackProcessedDate the feedback processed date
  394.      *
  395.      * @return self
  396.      */
  397.     public function setFeedbackProcessedDate($feedbackProcessedDate)
  398.     {
  399.         $this->feedbackProcessedDate $feedbackProcessedDate;
  400.     }
  401.     /**
  402.      * Gets the Survey comments.
  403.      *
  404.      * @return string
  405.      */
  406.     public function getComments()
  407.     {
  408.         return $this->comments;
  409.     }
  410.     /**
  411.      * Sets the Survey comments.
  412.      *
  413.      * @param string $comments the comments
  414.      *
  415.      * @return self
  416.      */
  417.     public function setComments($comments)
  418.     {
  419.         $this->comments $comments;
  420.     }
  421.     /**
  422.      * Gets the Survey comments.
  423.      *
  424.      * @return string
  425.      */
  426.     public function getCustomerMessage()
  427.     {
  428.         return $this->customerMessage;
  429.     }
  430.     /**
  431.      * Sets the Survey comments.
  432.      *
  433.      * @param string $customerMessage the customer message
  434.      *
  435.      * @return self
  436.      */
  437.     public function setCustomerMessage($customerMessage)
  438.     {
  439.         $this->customerMessage $customerMessage;
  440.     }
  441.     /**
  442.      * Gets the Survey assigned manager.
  443.      *
  444.      * @return \XLite\Model\Profile
  445.      */
  446.     public function getManager()
  447.     {
  448.         return $this->manager;
  449.     }
  450.     /**
  451.      * Sets the Survey assigned manager.
  452.      *
  453.      * @param \XLite\Model\Profile $manager the manager
  454.      *
  455.      * @return self
  456.      */
  457.     public function setManager(\XLite\Model\Profile $manager)
  458.     {
  459.         $this->manager $manager;
  460.     }
  461.     /**
  462.      * Gets the Survey customer.
  463.      *
  464.      * @return \XLite\Model\Profile
  465.      */
  466.     public function getCustomer()
  467.     {
  468.         return $this->customer;
  469.     }
  470.     /**
  471.      * Sets the Survey customer.
  472.      *
  473.      * @param \XLite\Model\Profile $customer the customer
  474.      *
  475.      * @return self
  476.      */
  477.     public function setCustomer($customer)
  478.     {
  479.         $this->customer $customer;
  480.     }
  481.     /**
  482.      * Gets the Relations to a Answer entities.
  483.      *
  484.      * @return \Doctrine\Common\Collections\Collection
  485.      */
  486.     public function getAnswers()
  487.     {
  488.         return $this->answers;
  489.     }
  490.     /**
  491.      * Sets the Relations to a Answer entities.
  492.      *
  493.      * @param \Doctrine\Common\Collections\Collection $answers the answers
  494.      *
  495.      * @return self
  496.      */
  497.     public function setAnswers($answers)
  498.     {
  499.         $this->answers $answers;
  500.     }
  501.     /**
  502.      * Gets the Relation to a TagSurvey entities.
  503.      *
  504.      * @return \QSL\CustomerSatisfaction\Model\Tag
  505.      */
  506.     public function getTags()
  507.     {
  508.         return $this->tags;
  509.     }
  510.     /**
  511.      * Sets the Relation to a TagSurvey entities.
  512.      *
  513.      * @param \QSL\CustomerSatisfaction\Model\Tag $tags the tags
  514.      *
  515.      * @return self
  516.      */
  517.     public function setTags($tags)
  518.     {
  519.         $this->tags $tags;
  520.     }
  521.     /**
  522.      * Gets the Hash key.
  523.      *
  524.      * @return string
  525.      */
  526.     public function getHashKey()
  527.     {
  528.         return $this->hashKey;
  529.     }
  530.     /**
  531.      * Sets the Hash key.
  532.      *
  533.      * @param string $hashKey the hash key
  534.      *
  535.      * @return self
  536.      */
  537.     public function setHashKey($hashKey)
  538.     {
  539.         $this->hashKey $hashKey;
  540.     }
  541.     /**
  542.      * Gets the Question is enabled.
  543.      *
  544.      * @return boolean
  545.      */
  546.     public function getFilled()
  547.     {
  548.         return $this->filled;
  549.     }
  550.     /**
  551.      * Sets the Question is enabled.
  552.      *
  553.      * @param boolean $filled the filled
  554.      *
  555.      * @return self
  556.      */
  557.     public function setFilled($filled)
  558.     {
  559.         $this->filled $filled;
  560.     }
  561. }