src/Entity/Partner.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use App\Entity\NotificationInLicensorBell;
  5. use Symfony\Component\Validator\Constraints as Assert;
  6. /**
  7.  * Partner
  8.  * @ORM\Table(name="partner")
  9.  * @ORM\Entity(repositoryClass="App\Repository\PartnerRepository")
  10.  */
  11. class Partner {
  12.     // Contantes de eliminación lógica 
  13.     const NOT_DELETED 0;
  14.     const DELETED 1;
  15.     
  16.     // Constantes de estado
  17.     const ACTIVE =1;
  18.     const INACTIVE =2;
  19.     // Constantes de notificación de primer registro que se le envía al agente
  20.     const PARTNER_NOT_NOTIFIED 1;
  21.     const PARTNER_NOTIFIED 1;
  22.     
  23.     // Constantes que representa si un partner ya fue visualizado y seleccionado en la tabla de new leads en dashboard
  24.     const NOT_CHECKED_BY_AGENT 0;
  25.     const CHECKED_BY_AGENT 1;
  26.     CONST VIEW_CHECK_BY_AGENT 2
  27.     // constante que indica el nombre del tag por defecto que recibirá y validara LEVELPOS
  28.     const DEFAULT_TAG_NAME_FOR_LEVELPOS 'DEMO';
  29.     const TAG_FOR_LEVELPOS_RESTAURANT_DEMO 'RESTAURANT DEMO';
  30.     /**
  31.      * @var integer
  32.      * @ORM\Column(name="p_id", type="integer")
  33.      * @ORM\Id
  34.      * @ORM\GeneratedValue(strategy="IDENTITY")
  35.      */
  36.     private $id;
  37.     /**
  38.      * @var string
  39.      * @ORM\Column(name="p_full_name", type="string", nullable=false)
  40.      */
  41.     private $fullName;
  42.     /**
  43.      * @var string
  44.      * @ORM\Column(name="p_company_name", type="string", nullable=true)
  45.      */
  46.     private $companyName;
  47.     /**
  48.      * @var int|null
  49.      * @var \App\Entity\Company
  50.      * @ORM\ManyToOne(targetEntity="App\Entity\Company")
  51.      * @ORM\JoinColumns({
  52.      *   @ORM\JoinColumn(name="p_company", referencedColumnName="co_id", nullable=true, onDelete="CASCADE")
  53.      * })
  54.      */
  55.     private $company;
  56.     /**
  57.      * @var int|null
  58.      * @var \App\Entity\Account
  59.      * @ORM\ManyToOne(targetEntity="App\Entity\Account")
  60.      * @ORM\JoinColumns({
  61.      *   @ORM\JoinColumn(name="p_account", referencedColumnName="ac_id", nullable=true, onDelete="CASCADE")
  62.      * })
  63.      */
  64.     private $account;
  65.     /**
  66.      * @var string
  67.      * @ORM\Column(name="p_email", type="string", nullable=true)
  68.      * @Assert\Email(message = "The email '{{ value }}' is not valid")
  69.      */
  70.     private $email;
  71.     /**
  72.      * @var string
  73.      * @ORM\Column(name="p_zip", type="string", length=50, nullable=true)
  74.      */
  75.     private $zip;
  76.     /**
  77.      * @var string
  78.      * @ORM\Column(name="p_phone", type="string", length=50, nullable=true)
  79.      */
  80.     private $phone;
  81.     /**
  82.      * @var string
  83.      * @ORM\Column(name="p_landline_phone", type="string", length=50, nullable=true)
  84.      */
  85.     private $landlinePhone;
  86.     /**
  87.      * @var string
  88.      * @ORM\Column(name="p_landline_phone_ext", type="string", length=50, nullable=true)
  89.      */
  90.     private $landlinePhoneExt;
  91.     /**
  92.      * @var integer
  93.      * @ORM\Column(name="p_portafolio_size", type="string", nullable=true)
  94.      */
  95.     private $portafolioSize;
  96.     /**
  97.      * @var integer
  98.      * @ORM\Column(name="p_monthly_restaurant_sales", type="string", nullable=true)
  99.      */
  100.     private $monthlyRestaurantSales;
  101.     /**
  102.      * @var string
  103.      * @ORM\Column(name="p_number_agent", type="string", nullable=true)
  104.      */
  105.     private $numberAgent;
  106.     /**
  107.      * @var \DateTime
  108.      * @ORM\Column(name="p_created_time_frame", type="datetime", nullable=true)
  109.      */
  110.     private $createdTimeFrame;
  111.     /**
  112.      * @var integer
  113.      * @ORM\Column(name="p_time_frame", type="integer", nullable=true)
  114.      */
  115.     private $timeFrame;
  116.     /**
  117.      * @var \App\Entity\User
  118.      * @ORM\ManyToOne(targetEntity="App\Entity\User")
  119.      * @ORM\JoinColumns({
  120.      *   @ORM\JoinColumn(name="p_user", referencedColumnName="us_id", nullable=true, onDelete="CASCADE")
  121.      * })
  122.      */
  123.     private $user;
  124.     /**
  125.     * @var string
  126.     * @ORM\Column(name="p_deleted", type="boolean", nullable=true)
  127.     */
  128.     private $deleted 0;
  129.     /**
  130.      * @var \App\Entity\Country
  131.      * @ORM\ManyToOne(targetEntity="App\Entity\Country")
  132.      * @ORM\JoinColumns({
  133.      *   @ORM\JoinColumn(name="p_country", referencedColumnName="co_id", nullable=true)
  134.      * })
  135.      */
  136.     private $country;
  137.     
  138.     /**
  139.      * @var \App\Entity\State
  140.      * @ORM\ManyToOne(targetEntity="App\Entity\State")
  141.      * @ORM\JoinColumns({
  142.      *   @ORM\JoinColumn(name="p_state", referencedColumnName="st_id", nullable=true)
  143.      * })
  144.      */
  145.     private $state;
  146.     /**
  147.      * @var boolean
  148.      * @ORM\Column(name="p_is_other_country", type="boolean", nullable=true)
  149.      */
  150.     private $isOtherCountry;
  151.     
  152.     /**
  153.      * @var string
  154.      * @ORM\Column(name="p_other_country", type="string", length=50, nullable=true)
  155.      */
  156.     private $otherCountry;
  157.     /**
  158.      * @var \App\Entity\Timezone
  159.      * @ORM\ManyToOne(targetEntity="App\Entity\Timezone")
  160.      * @ORM\JoinColumns({
  161.      *   @ORM\JoinColumn(name="p_time_zone", referencedColumnName="tm_id", nullable=true)
  162.      * })
  163.      */
  164.     private $timeZone;
  165.     /**
  166.      * @var integer
  167.      * @ORM\Column(name="p_notified", type="integer", nullable=true)
  168.      */
  169.     private $notified;
  170.     /**
  171.      * @var integer
  172.      * @ORM\Column(name="p_is_checked_by_agent", type="integer", nullable=true)
  173.      */
  174.     private $isCheckedByAgent 0;
  175.     /**
  176.      * @var \DateTime
  177.      * @ORM\Column(name="p_date_attempted_registration", type="datetime", nullable=true)
  178.     */
  179.     private $dateAttemptedRegistration;
  180.     /**
  181.      * @var boolean
  182.      * @ORM\Column(name="p_lead_need_demo", type="boolean", nullable=false, options={"default":false})
  183.      */
  184.     private $leadNeedDemo false;
  185.     /**
  186.      * @var boolean
  187.      * @ORM\Column(name="p_lead_perspect_account", type="boolean", nullable=false, options={"default":false})
  188.      */
  189.     private $leadPerspectAccount false;
  190.     /**
  191.      * @var boolean
  192.      * @ORM\Column(name="p_restraurant_demo", type="boolean", nullable=false, options={"default":false})
  193.      */
  194.     private $isRestraurantDemo false;
  195.     /**
  196.      * @var string
  197.      * @ORM\Column(name="p_number_locations", type="string", nullable=true)
  198.      */
  199.     private $numberLocations;
  200.     /**
  201.      * @var string
  202.      * @ORM\Column(name="p_type_business", type="string", nullable=true)
  203.      */
  204.     private $typeBusiness;
  205.     /**
  206.      * @var string
  207.      * @ORM\Column(name="p_number_stations", type="string", nullable=true)
  208.      */
  209.     private $numberStations;
  210.     /**
  211.      * @var string
  212.      * @ORM\Column(name="p_res_time_frame", type="string", nullable=true)
  213.      */
  214.     private $resTimeFrame;
  215.     /**
  216.      * @return string
  217.      */
  218.     public function __toString() {
  219.         return "" $this->getFullName();
  220.     }
  221.     public function getId(){
  222.         return $this->id;
  223.     }
  224.     public function getFullName(){
  225.         return $this->fullName;
  226.     }
  227.     public function setFullName(string $fullName){
  228.         $this->fullName $fullName;
  229.     }
  230.     public function setCompanyName(string $companyName){
  231.         $this->companyName $companyName;
  232.     }
  233.     public function getCompanyName(){
  234.         return $this->companyName;
  235.     }
  236.     public function getCompany(){
  237.         return $this->company;
  238.     }
  239.     public function setCompany($company){
  240.         $this->company $company;
  241.     }
  242.     public function getEmail(){
  243.         return $this->email;
  244.     }
  245.  
  246.     public function setEmail(string $email){
  247.         $this->email $email;
  248.     }
  249.     public function getZip(){
  250.         return $this->zip;
  251.     }
  252.     public function setZip(string $zip){
  253.         $this->zip $zip;
  254.     }
  255.     public function getPhone(){
  256.         return $this->phone;
  257.     }
  258.  
  259.     public function setPhone(string $phone){
  260.         $this->phone $phone;
  261.     }
  262.     public function getLandlinePhone(){
  263.         return $this->landlinePhone;
  264.     }
  265.     public function setLandlinePhone(string $landlinePhone){
  266.         $this->landlinePhone $landlinePhone;
  267.     }
  268.     public function getLandlinePhoneExt(){
  269.         return $this->landlinePhoneExt;
  270.     }
  271.     public function setLandlinePhoneExt(string $landlinePhoneExt){
  272.         $this->landlinePhoneExt $landlinePhoneExt;
  273.     }
  274.     public function getPortafolioSize(){
  275.         return $this->portafolioSize;
  276.     }
  277.     public function setPortafolioSize($portafolioSize){
  278.         $this->portafolioSize $portafolioSize;
  279.     }
  280.  
  281.     public function getMonthlyRestaurantSales(){
  282.         return $this->monthlyRestaurantSales;
  283.     }
  284.     public function setMonthlyRestaurantSales($monthlyRestaurantSales){
  285.         $this->monthlyRestaurantSales $monthlyRestaurantSales;
  286.         return $this;
  287.     }
  288.     public function getNumberAgent(){
  289.         return $this->numberAgent;
  290.     }
  291.     public function setNumberAgent(string $numberAgent){
  292.         $this->numberAgent $numberAgent;
  293.     }
  294.     public function getCreatedTimeFrame(){
  295.         return $this->createdTimeFrame;
  296.     }
  297.     public function setCreatedTimeFrame(\DateTime $createdTimeFrame){
  298.         $this->createdTimeFrame $createdTimeFrame;
  299.     }
  300.     public function getTimeFrame(){
  301.         return $this->timeFrame;
  302.     }
  303.  
  304.     public function setTimeFrame($timeFrame){
  305.         $this->timeFrame $timeFrame;
  306.     }
  307.     public function getUser(){
  308.         return $this->user;
  309.     }
  310.     public function setUser($user){
  311.         $this->user $user;
  312.     }
  313.     public function getDeleted() {
  314.         return $this->deleted;
  315.     }
  316.     public function setDeleted($deleted) {
  317.         $this->deleted $deleted;
  318.     }
  319.     public static function filterSearchParameters($alias$otherAlias$search) {
  320.         $textParameters $join '';
  321.         $parameters = [];
  322.         if (isset($search['fullName']) && $search['fullName'] != '') {
  323.             $textParameters .= " AND $alias.p_full_name LIKE ? ";
  324.             $parameters[] = "%" $search['fullName'] . "%";
  325.         }
  326.         if (isset($search['companyName']) && $search['companyName'] != '') {
  327.             $textParameters .= " AND $alias.p_company_name LIKE ? ";
  328.             $parameters[] = "%" $search['companyName'] . "%";
  329.         }
  330.         if (isset($search['email']) && $search['email'] != '') {
  331.             $textParameters .= " AND $alias.p_email LIKE ? ";
  332.             $parameters[] = "%" $search['email'] . "%";
  333.         }
  334.         if (isset($search['phone']) && $search['phone'] != '') {
  335.             $textParameters .= " AND $alias.p_phone = ? ";
  336.             $parameters[] = $search['phone'];
  337.         }
  338.         if (isset($search['zip']) && $search['zip'] != '') {
  339.             $textParameters .= " AND $alias.p_zip = ? ";
  340.             $parameters[] = $search['zip'];
  341.         }
  342.         if (isset($search['timeFrame']) && $search['timeFrame'] != '') {
  343.             $textParameters .= " AND $alias.p_time_frame = ? ";
  344.             $parameters[] = $search['timeFrame'];
  345.         }
  346.         if (isset($search['status']) && (int) $search['status'] == self::ACTIVE) {
  347.             $textParameters .= " AND (CASE WHEN {$otherAlias['asPlanningTask']}.pt_id IS NULL THEN false ELSE true END) = ? ";
  348.             $parameters[] = true;
  349.         }
  350.         if (isset($search['status']) && (int) $search['status'] == self::INACTIVE) {
  351.             $textParameters .= " AND (CASE WHEN {$otherAlias['asPlanningTask']}.pt_id IS NULL THEN false ELSE true END) = ? ";
  352.             $parameters[] = false;
  353.         }
  354.         if (isset($search['leadPerspectAccount']) && is_bool($search['leadPerspectAccount'])) {
  355.             $textParameters .= " AND P.p_lead_perspect_account = ? ";
  356.             $parameters[] = $search['leadPerspectAccount'];
  357.         }
  358.     
  359.         if (isset($search['user']) && $search['user'] != '') {
  360.             $textParameters .= " AND {$otherAlias['asUser']}.us_id = ? ";
  361.             $parameters[] = $search['user'];
  362.             $join .= " JOIN user {$otherAlias['asUser']} ON {$otherAlias['asUser']}.us_id = $alias.p_user ";
  363.         }
  364.         
  365.         if (isset($search['company']) && $search['company'] != '') {
  366.             $textParameters .= " AND {$otherAlias['asUser']}.us_company_id = ? ";
  367.             $parameters[] = $search['company'];
  368.             if(isset($search['user']) && $search['user'] != ''){
  369.                 $join .= " JOIN company {$otherAlias['asCompany']} ON {$otherAlias['asCompany']}.co_id = {$otherAlias['asUser']}.us_company_id";
  370.             }else{
  371.                 $join .= " JOIN user {$otherAlias['asUser']} ON {$otherAlias['asUser']}.us_id = $alias.p_user 
  372.                                 JOIN company {$otherAlias['asCompany']} ON {$otherAlias['asCompany']}.co_id = {$otherAlias['asUser']}.us_company_id ";
  373.             }
  374.         }
  375.         
  376.         return ['text' => $textParameters'parameters' => $parameters'join' => $join];
  377.     }
  378.     /**
  379.      * filter order parameters para consulta DQL segun el order solicitado
  380.      * @param String $alias
  381.      * @param String $secondAlias
  382.      * @param Array $order
  383.      * @return string el ORDER BY adecuado segun corresponda
  384.      */
  385.     public static function filterOrderParameters($alias$order) {
  386.         // se tiene que enviar '0' para que el ordenamiento sea ASC y '1' para que sea DESC
  387.         
  388.         $orderBy " ORDER BY $alias.p_created_time_frame DESC, $alias.p_full_name ASC ";
  389.         if (isset($order['fullName']) && $order['fullName'] != '') {
  390.             $orderBy " ORDER BY $alias.p_full_name ";
  391.             $orderBy .= ($order['fullName'] % 2) ? "DESC" "ASC";
  392.         }
  393.         
  394.         if (isset($order['companyName']) && $order['companyName'] != '') {
  395.             $orderBy " ORDER BY $alias.p_company_name ";
  396.             $orderBy .= ($order['companyName'] % 2) ? "DESC" "ASC";
  397.         }
  398.         
  399.         if (isset($order['email']) && $order['email'] != '') {
  400.             $orderBy " ORDER BY $alias.p_email ";
  401.             $orderBy .= ($order['email'] % 2) ? "DESC" "ASC";
  402.         }
  403.         
  404.         if (isset($order['createdTimeFrame']) && $order['createdTimeFrame'] != '') {
  405.             $orderBy " ORDER BY $alias.p_created_time_frame ";
  406.             $orderBy .= ($order['createdTimeFrame'] % 2) ? "DESC" "ASC";
  407.         }
  408.     
  409.         if (isset($order['user']) && $order['user'] != '') {
  410.             $orderBy " ORDER BY $alias.p_user ";
  411.             $orderBy .= ($order['user'] % 2) ? "DESC" "ASC";
  412.         }
  413.         if (isset($order['company']) && $order['company'] != '') {
  414.             $orderBy " ORDER BY $alias.p_company ";
  415.             $orderBy .= ($order['company'] % 2) ? "DESC" "ASC";
  416.         }
  417.         return $orderBy;
  418.     }
  419.     
  420.     public function getCountry()
  421.     {
  422.         return $this->country;
  423.     }
  424.     public function setCountry($country)
  425.     {
  426.         $this->country $country;
  427.     }
  428.  
  429.     public function getState()
  430.     {
  431.         return $this->state;
  432.     }
  433.     public function setState($state)
  434.     {
  435.         $this->state $state;
  436.     }
  437.     public function getIsOtherCountry()
  438.     {
  439.         return $this->isOtherCountry;
  440.     }
  441.     public function setIsOtherCountry($isOtherCountry)
  442.     {
  443.         $this->isOtherCountry $isOtherCountry;
  444.     }
  445.     public function getOtherCountry()
  446.     {
  447.         return $this->otherCountry;
  448.     }
  449.     public function setOtherCountry(string $otherCountry)
  450.     {
  451.         $this->otherCountry $otherCountry;
  452.         return $this;
  453.     }
  454.     public function getTimeZone()
  455.     {
  456.         return $this->timeZone;
  457.     }
  458.     public function setTimeZone($timeZone)
  459.     {
  460.         $this->timeZone $timeZone;
  461.         return $this;
  462.     }
  463.     public function getNotified() {
  464.         return $this->notified;
  465.     }
  466.     public function setNotified(int $notified) {
  467.         $this->notified $notified;
  468.         return $this;
  469.     }
  470.     public function getIsCheckedByAgent() {
  471.         return $this->isCheckedByAgent;
  472.     }
  473.     public function setIsCheckedByAgent(int $isCheckedByAgent) {
  474.         $this->isCheckedByAgent $isCheckedByAgent;
  475.         return $this;
  476.     }
  477.     
  478.     public function getDateAttemptedRegistration(){
  479.         return $this->dateAttemptedRegistration;
  480.     }
  481.     public function setDateAttemptedRegistration($dateAttemptedRegistration){
  482.         $this->dateAttemptedRegistration $dateAttemptedRegistration;
  483.         return $this;
  484.     }
  485.     /**
  486.      * Función para pasar a de tipo objeto-entidad a json
  487.      */
  488.     public function showEverything() {
  489.         return get_object_vars($this);
  490.     }
  491.     /**
  492.      * Get the value of leadNeedDemo
  493.      */
  494.     public function getLeadNeedDemo(){
  495.         return $this->leadNeedDemo;
  496.     }
  497.     /**
  498.      * Set the value of leadNeedDemo
  499.      */
  500.     public function setLeadNeedDemo($leadNeedDemo){
  501.         $this->leadNeedDemo $leadNeedDemo;
  502.     }
  503.     /**
  504.      * Get the value of leadPerspectAccount
  505.      */
  506.     public function getLeadPerspectAccount(){
  507.         return $this->leadPerspectAccount;
  508.     }
  509.     /**
  510.      * Set the value of leadPerspectAccount
  511.      */
  512.     public function setLeadPerspectAccount($leadPerspectAccount){
  513.         $this->leadPerspectAccount $leadPerspectAccount;
  514.     }
  515.     public function getAccount()
  516.     {
  517.         return $this->account;
  518.     }
  519.     public function setAccount($account)
  520.     {
  521.         $this->account $account;
  522.     }
  523.     public function getIsRestraurantDemo(){
  524.         return $this->isRestraurantDemo;
  525.     }
  526.     public function setIsRestraurantDemo($isRestraurantDemo){
  527.         $this->isRestraurantDemo $isRestraurantDemo;
  528.     }
  529.     public function getNumberLocations(){
  530.         return $this->numberLocations;
  531.     }
  532.     public function setNumberLocations(string $numberLocations){
  533.         $this->numberLocations $numberLocations;
  534.     }
  535.     public function getTypeBusiness(){
  536.         return $this->typeBusiness;
  537.     }
  538.     public function setTypeBusiness(string $typeBusiness){
  539.         $this->typeBusiness $typeBusiness;
  540.     }
  541.     public function getNumberStations(){
  542.         return $this->numberStations;
  543.     }
  544.     public function setNumberStations(string $numberStations){
  545.         $this->numberStations $numberStations;
  546.     }
  547.     public function getResTimeFrame(){
  548.         return $this->resTimeFrame;
  549.     }
  550.     public function setResTimeFrame(string $resTimeFrame){
  551.         $this->resTimeFrame $resTimeFrame;
  552.     }
  553. }