src/Entity/LicenseDataBase.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. /**
  5.  * Description of LicenseDataBase
  6.  * @ORM\Table(name="license_database")
  7.  * @ORM\Entity(repositoryClass="App\Repository\LicenseDataBaseRepository")
  8.  * @ORM\HasLifecycleCallbacks
  9.  */
  10. class LicenseDataBase {
  11.     /**
  12.      * constantes para el esto de la creacion de las bases de datos
  13.      */
  14.     const LICENSE_DATABASE_STATUS_NULL 1;
  15.     const LICENSE_DATABASE_STATUS_HALF 2;
  16.     const LICENSE_DATABASE_STATUS_FULL 3;
  17.     /**
  18.      * @var integer
  19.      * @ORM\Column(name="lida_id", type="integer")
  20.      * @ORM\Id
  21.      * @ORM\GeneratedValue(strategy="IDENTITY")
  22.      */
  23.     private $id;
  24.     /**
  25.      * @var string
  26.      * @ORM\Column(name="lida_dbhost", type="string", length=50, nullable=false)
  27.      */
  28.     private $dbhost;
  29.     /**
  30.      * @var string
  31.      * @ORM\Column(name="lida_dbname", type="string", length=50, nullable=false)
  32.      */
  33.     private $dbname;
  34.     /**
  35.      *  @var float
  36.      *  @ORM\Column(name="lida_dbuser", type="string", length=50, nullable=true) 
  37.      */
  38.     protected $dbuser;
  39.     /**
  40.      * @var string
  41.      * @ORM\Column(name="lida_dbpass", type="string", length=50) 
  42.      */
  43.     protected $dbpass;
  44.     /**
  45.      * Un modulo puede tener otro modulo padre, lo que lo hace un submodulo
  46.      * @ORM\ManyToOne(targetEntity="App\Entity\AccountLicense", cascade={"remove"})
  47.      * @ORM\JoinColumn(name="lida_license_id", referencedColumnName="al_id", nullable=false, unique=true, onDelete="CASCADE")
  48.      */
  49.     protected $license;
  50.     /**
  51.      * @var boolean
  52.      * @ORM\Column(name="lida_database_created", type="boolean", nullable=true)
  53.      */
  54.     private $isDatabaseCreated;
  55.     /**
  56.      * @var boolean
  57.      * @ORM\Column(name="lida_schema_created", type="boolean", nullable=true)
  58.      */
  59.     private $isSchemaCreated;
  60.     /**
  61.      * @var boolean
  62.      * @ORM\Column(name="lida_initial_insert_done", type="boolean", nullable=true)
  63.      */
  64.     private $isInitialInsert;
  65.     /**
  66.      * @var boolean
  67.      * @ORM\Column(name="lida_initial_data_configured", type="boolean", nullable=true)
  68.      */
  69.     private $isInitialConfigured;
  70.     /**
  71.      * @var string
  72.      * @ORM\Column(name="lida_has_error", type="boolean", nullable=true, options={"default":"0"})
  73.      */
  74.     private $hasPersistentError;
  75.     /**
  76.      * @var DateTime
  77.      * @ORM\Column(name="lida_date_cron_last_schema", type="datetime", nullable=true)
  78.      */
  79.     private $dateCronLastSchemaLicense;
  80.     /**
  81.      * @var DateTime
  82.      * @ORM\Column(name="lida_date_cron_last_procedure", type="datetime", nullable=true)
  83.      */
  84.     private $dateCronLastLicense;
  85.     public function showEverything() {
  86.         return get_object_vars($this);
  87.     }
  88.     /**
  89.      * @return type
  90.      */
  91.     public function getId() {
  92.         return $this->id;
  93.     }
  94.     /**
  95.      * @return type
  96.      */
  97.     public function getDbhost() {
  98.         return $this->dbhost;
  99.     }
  100.     /**
  101.      * @return type
  102.      */
  103.     public function getDbname() {
  104.         return $this->dbname;
  105.     }
  106.     /**
  107.      * @return type
  108.      */
  109.     public function getDbuser() {
  110.         return $this->dbuser;
  111.     }
  112.     /**
  113.      * @return type
  114.      */
  115.     public function getDbpass() {
  116.         return $this->dbpass;
  117.     }
  118.     /**
  119.      * @return type
  120.      */
  121.     public function getLicense() {
  122.         return $this->license;
  123.     }
  124.     /**
  125.      * @param type $dbhost
  126.      */
  127.     public function setDbhost($dbhost) {
  128.         $this->dbhost $dbhost;
  129.     }
  130.     /**
  131.      * @param type $dbname
  132.      */
  133.     public function setDbname($dbname) {
  134.         $this->dbname $dbname;
  135.     }
  136.     /**
  137.      * @param type $dbuser
  138.      */
  139.     public function setDbuser($dbuser) {
  140.         $this->dbuser $dbuser;
  141.     }
  142.     /**
  143.      * @param type $dbpass
  144.      */
  145.     public function setDbpass($dbpass) {
  146.         $this->dbpass $dbpass;
  147.     }
  148.     /**
  149.      * @param \App\Entity\AccountLicense $license
  150.      */
  151.     public function setLicense(\App\Entity\AccountLicense $license) {
  152.         $this->license $license;
  153.     }
  154.     /**
  155.      * @return type
  156.      */
  157.     public function getIsDatabaseCreated() {
  158.         return $this->isDatabaseCreated;
  159.     }
  160.     /**
  161.      * @param type $isDatabaseCreated
  162.      */
  163.     public function setIsDatabaseCreated($isDatabaseCreated) {
  164.         $this->isDatabaseCreated $isDatabaseCreated;
  165.     }
  166.     /**
  167.      * @return type
  168.      */
  169.     public function getIsSchemaCreated() {
  170.         return $this->isSchemaCreated;
  171.     }
  172.     /**
  173.      * @param type $isSchemaCreated
  174.      */
  175.     public function setIsSchemaCreated($isSchemaCreated) {
  176.         $this->isSchemaCreated $isSchemaCreated;
  177.     }
  178.     /**
  179.      * @return type
  180.      */
  181.     public function getHasPersistentError() {
  182.         return $this->hasPersistentError;
  183.     }
  184.     /**
  185.      * @param type $hasPersistentError
  186.      */
  187.     public function setHasPersistentError($hasPersistentError) {
  188.         $this->hasPersistentError $hasPersistentError;
  189.     }
  190.     /**
  191.      * @return type
  192.      */
  193.     public function getDateCronLastLicense() {
  194.         return $this->dateCronLastLicense;
  195.     }
  196.     /**
  197.      * @param type $dateCronLastLicense
  198.      */
  199.     public function setDateCronLastLicense($dateCronLastLicense) {
  200.         $this->dateCronLastLicense $dateCronLastLicense;
  201.     }
  202.     /**
  203.      * @return type
  204.      */
  205.     public function getDateCronLastSchemaLicense() {
  206.         return $this->dateCronLastSchemaLicense;
  207.     }
  208.     /**
  209.      * @param type $dateCronLastSchemaLicense
  210.      */
  211.     public function setDateCronLastSchemaLicense($dateCronLastSchemaLicense) {
  212.         $this->dateCronLastSchemaLicense $dateCronLastSchemaLicense;
  213.     }
  214.     /**
  215.      * @return type
  216.      */
  217.     public function getIsInitialInsert() {
  218.         return $this->isInitialInsert;
  219.     }
  220.     /**
  221.      * @param type $isInitialInsert
  222.      */
  223.     public function setIsInitialInsert($isInitialInsert) {
  224.         $this->isInitialInsert $isInitialInsert;
  225.     }
  226.     /**
  227.      * @return type
  228.      */
  229.     public function getIsInitialConfigured() {
  230.         return $this->isInitialConfigured;
  231.     }
  232.     /**
  233.      * @param type $isInitialConfigured
  234.      */
  235.     public function setIsInitialConfigured($isInitialConfigured) {
  236.         $this->isInitialConfigured $isInitialConfigured;
  237.     }
  238.     /**
  239.      * Funcion para realizar el filtrado de parametros de busqueda
  240.      * correspondientes a esta entidad
  241.      * @author Aealan Z <lrobledo@kijho.com> 29/07/2016
  242.      * @param type $alias salchichas y mucho mas
  243.      * @param type $search arreglo con los parametros de busqueda a filtrar
  244.      * correspondientes a la entidad
  245.      * @return type un arreglo con un arreglo que contiene los parametros de
  246.      * busqueda filtrados para una consulta y un string que sera parte del DQL
  247.      * que realizara la busqueda correspondiente de las entidades en la base
  248.      * de datos
  249.      */
  250.     public static function filterSearchParameters($alias$secondAlias$search) {
  251.         $textParameters $join '';
  252.         $parameters = [];
  253.         if (isset($search ['alLicenseUsername']) && $search ['alLicenseUsername'] != '') {
  254.             $textParameters .= " AND " $secondAlias ".alLicenseUsername LIKE :alLicenseUsername";
  255.             $parameters ['alLicenseUsername'] = "%" $search ['alLicenseUsername'] . "%";
  256.         }
  257.         if (isset($search ['dbname']) && $search ['dbname'] != '') {
  258.             $textParameters .= " AND " $alias ".dbname LIKE :dbname";
  259.             $parameters ['dbname'] = "%" $search ['dbname'] . "%";
  260.         }
  261.         if (isset($search['account']) && $search['account'] != '') {
  262.             $parameters['account'] = $search['account'];
  263.             $textParameters .= " AND " $secondAlias ".alAccountLicense = :account";
  264.         }
  265.         if (isset($search ['deviceUid']) && $search ['deviceUid'] != '') {
  266.             $textParameters .= " AND " $secondAlias ".deviceUid LIKE :deviceUid";
  267.             $parameters ['deviceUid'] = "%" $search ['deviceUid'] . "%";
  268.         }
  269.         if (isset($search['user']) && $search['user'] instanceof User && $search['user']->getUsType() != User::USER_SUPER_ADMIN && $search['user']->getUsType() != User::USER_INTERNAL_SUPPORT) {
  270.             if ($search['user']->getUsType() == User::USER_ADMINISTRATOR) {
  271.                 // $join = " LEFT JOIN App\Entity\User U WITH $secondAlias.alUserCreator = U.id ";
  272.                 $textParameters .= " AND $secondAlias.alCompanyId = :USER_COMPANY ";
  273.                 $parameters['USER_COMPANY'] = $search['user']->getUsCompany()->getId();
  274.             }else{
  275.                 $textParameters .= " AND " $secondAlias ".alUserCreator = :USERCREATOR";
  276.                 $parameters['USERCREATOR'] = $search['user']->getId();
  277.             }
  278.         }
  279.         return ['text' => $textParameters'parameters' => $parameters'join' => $join];
  280.     }
  281.     /**
  282.      * Funcion que permite filtrar los parametros de ordenamiento para la
  283.      * entidad y retornar un DQL para realizar la consulta pertienete en la
  284.      * base de datos
  285.      * @author Aealan Z <lrobledo@kijho.com> 29/07/2016
  286.      * @param type $alias salchichas y mucho mas
  287.      * @param type $order array que contiene los parametros de ordenamiento
  288.      * para la entidad 
  289.      * @return string que contiene el DQL con los parametros de ordenamiento
  290.      * filtrados para esta entidad
  291.      */
  292.     public static function filterOrderParameters($alias$secondAlias$order) {
  293.         $orderBy ' ORDER BY ' $secondAlias '.id ASC';
  294.         if (isset($order ['order_by_nickname']) && $order ['order_by_nickname'] != '') {
  295.             if ($order ['order_by_nickname'] % 2) {
  296.                 $orderBy " ORDER BY " $secondAlias ".id DESC";
  297.             } else {
  298.                 $orderBy " ORDER BY " $secondAlias ".id ASC";
  299.             }
  300.         } elseif (isset($order ['order_by_dbname']) && $order ['order_by_dbname'] != '') {
  301.             if ($order ['order_by_dbname'] % 2) {
  302.                 $orderBy " ORDER BY " $alias ".dbname DESC";
  303.             } else {
  304.                 $orderBy " ORDER BY " $alias ".dbname ASC";
  305.             }
  306.         } 
  307.         return $orderBy;
  308.     }
  309. }