ソースを参照

Add branch tables see BT#7721

Julio Montoya 9 年 前
コミット
cb3f1a4628

+ 743 - 0
src/Chamilo/CoreBundle/Entity/BranchSync.php

@@ -0,0 +1,743 @@
+<?php
+/* For licensing terms, see /license.txt */
+
+namespace Chamilo\CoreBundle\Entity;
+
+use Doctrine\ORM\Mapping as ORM;
+use Gedmo\Mapping\Annotation as Gedmo;
+
+/**
+ * BranchSync
+ *
+ * @ORM\Table(name="branch_sync")
+ * @ORM\Entity(repositoryClass="Chamilo\CoreBundle\Entity\Repository\BranchSyncRepository")
+ * @Gedmo\Tree(type="nested")
+ */
+class BranchSync
+{
+    /**
+     * @var integer
+     *
+     * @ORM\Column(name="id", type="integer", nullable=false, unique=false)
+     * @ORM\Id
+     * @ORM\GeneratedValue
+     */
+    private $id;
+
+    /**
+     * @var integer
+     *
+     * @ORM\Column(name="access_url_id", type="integer", nullable=false, unique=false)
+     */
+    private $accessUrlId;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="unique_id", type="string", length=50, nullable=false, unique=true)
+     */
+    private $uniqueId;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="branch_name", type="string", length=250, nullable=false, unique=false)
+     */
+    private $branchName;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="description", type="text", nullable=true)
+     */
+    private $description;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="branch_ip", type="string", length=40, nullable=true, unique=false)
+     */
+    private $branchIp;
+
+    /**
+     * @var float
+     *
+     * @ORM\Column(name="latitude", type="decimal", nullable=true, unique=false)
+     */
+    private $latitude;
+
+    /**
+     * @var float
+     *
+     * @ORM\Column(name="longitude", type="decimal", nullable=true, unique=false)
+     */
+    private $longitude;
+
+    /**
+     * @var integer
+     *
+     * @ORM\Column(name="dwn_speed", type="integer", nullable=true, unique=false)
+     */
+    private $dwnSpeed;
+
+    /**
+     * @var integer
+     *
+     * @ORM\Column(name="up_speed", type="integer", nullable=true, unique=false)
+     */
+    private $upSpeed;
+
+    /**
+     * @var integer
+     *
+     * @ORM\Column(name="delay", type="integer", nullable=true, unique=false)
+     */
+    private $delay;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="admin_mail", type="string", length=250, nullable=true, unique=false)
+     */
+    private $adminMail;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="admin_name", type="string", length=250, nullable=true, unique=false)
+     */
+    private $adminName;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="admin_phone", type="string", length=250, nullable=true, unique=false)
+     */
+    private $adminPhone;
+
+    /**
+     * @var integer
+     *
+     * @ORM\Column(name="last_sync_trans_id", type="bigint", nullable=true, unique=false)
+     */
+    private $lastSyncTransId;
+
+    /**
+     * @var \DateTime
+     *
+     * @ORM\Column(name="last_sync_trans_date", type="datetime", nullable=true, unique=false)
+     */
+    private $lastSyncTransDate;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="last_sync_type", type="string", length=20, nullable=true, unique=false)
+     */
+    private $lastSyncType;
+
+     /**
+     * @var string
+     *
+     * @ORM\Column(name="ssl_pub_key", type="string", length=250, nullable=true, unique=false)
+     */
+    private $sslPubKey;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="branch_type", type="string", length=250, nullable=true, unique=false)
+     */
+    private $branchType;
+
+    /**
+     * @var integer
+     * @Gedmo\TreeLeft
+     * @ORM\Column(name="lft", type="integer", nullable=true, unique=false)
+     */
+    private $lft;
+
+    /**
+     * @var integer
+     * @Gedmo\TreeRight
+     * @ORM\Column(name="rgt", type="integer", nullable=true, unique=false)
+     */
+    private $rgt;
+
+    /**
+     * @var integer
+     * @Gedmo\TreeLevel
+     * @ORM\Column(name="lvl", type="integer", nullable=true, unique=false)
+     */
+    private $lvl;
+
+    /**
+     * @var integer
+     * @Gedmo\TreeRoot
+     * @ORM\Column(name="root", type="integer", nullable=true, unique=false)
+     */
+    private $root;
+
+    /**
+     * @var integer
+     *
+     * @ORM\Column(name="parent_id", type="integer", nullable=true, unique=false)
+     */
+    private $parentId;
+
+    /**
+     * @Gedmo\TreeParent
+     * @ORM\ManyToOne(targetEntity="BranchSync", inversedBy="children")
+     * @ORM\JoinColumn(name="parent_id", referencedColumnName="id", onDelete="SET NULL")
+     */
+    private $parent;
+
+    /**
+     * @ORM\OneToMany(targetEntity="BranchSync", mappedBy="parent")
+     * @ORM\OrderBy({"lft" = "ASC"})
+     */
+    private $children;
+
+    /**
+     * Constructor
+     */
+    public function __construct()
+    {
+        $this->uniqueId = sha1(uniqid());
+        // $this->lastSyncTransDate = new \DateTime();
+    }
+
+    /**
+     * Get id
+     *
+     * @return integer
+     */
+    public function getId()
+    {
+        return $this->id;
+    }
+
+    /**
+     * Set accessUrlId
+     *
+     * @param integer $accessUrlId
+     * @return BranchSync
+     */
+    public function setAccessUrlId($accessUrlId)
+    {
+        $this->accessUrlId = $accessUrlId;
+
+        return $this;
+    }
+
+    /**
+     * Get accessUrlId
+     *
+     * @return integer
+     */
+    public function getAccessUrlId()
+    {
+        return $this->accessUrlId;
+    }
+
+    /**
+     * Set branchName
+     *
+     * @param string $branchName
+     * @return BranchSync
+     */
+    public function setBranchName($branchName)
+    {
+        $this->branchName = $branchName;
+
+        return $this;
+    }
+
+    /**
+     * Get branchName
+     *
+     * @return string
+     */
+    public function getBranchName()
+    {
+        return $this->branchName;
+    }
+
+    /**
+     * Set branchIp
+     *
+     * @param string $branchIp
+     * @return BranchSync
+     */
+    public function setBranchIp($branchIp)
+    {
+        $this->branchIp = $branchIp;
+
+        return $this;
+    }
+
+    /**
+     * Get branchIp
+     *
+     * @return string
+     */
+    public function getBranchIp()
+    {
+        return $this->branchIp;
+    }
+
+    /**
+     * Set latitude
+     *
+     * @param float $latitude
+     * @return BranchSync
+     */
+    public function setLatitude($latitude)
+    {
+        $this->latitude = $latitude;
+
+        return $this;
+    }
+
+    /**
+     * Get latitude
+     *
+     * @return float
+     */
+    public function getLatitude()
+    {
+        return $this->latitude;
+    }
+
+    /**
+     * Set longitude
+     *
+     * @param float $longitude
+     * @return BranchSync
+     */
+    public function setLongitude($longitude)
+    {
+        $this->longitude = $longitude;
+
+        return $this;
+    }
+
+    /**
+     * Get longitude
+     *
+     * @return float
+     */
+    public function getLongitude()
+    {
+        return $this->longitude;
+    }
+
+    /**
+     * Set dwnSpeed
+     *
+     * @param integer $dwnSpeed
+     * @return BranchSync
+     */
+    public function setDwnSpeed($dwnSpeed)
+    {
+        $this->dwnSpeed = $dwnSpeed;
+
+        return $this;
+    }
+
+    /**
+     * Get dwnSpeed
+     *
+     * @return integer
+     */
+    public function getDwnSpeed()
+    {
+        return $this->dwnSpeed;
+    }
+
+    /**
+     * Set upSpeed
+     *
+     * @param integer $upSpeed
+     * @return BranchSync
+     */
+    public function setUpSpeed($upSpeed)
+    {
+        $this->upSpeed = $upSpeed;
+
+        return $this;
+    }
+
+    /**
+     * Get upSpeed
+     *
+     * @return integer
+     */
+    public function getUpSpeed()
+    {
+        return $this->upSpeed;
+    }
+
+    /**
+     * Set delay
+     *
+     * @param integer $delay
+     * @return BranchSync
+     */
+    public function setDelay($delay)
+    {
+        $this->delay = $delay;
+
+        return $this;
+    }
+
+    /**
+     * Get delay
+     *
+     * @return integer
+     */
+    public function getDelay()
+    {
+        return $this->delay;
+    }
+
+    /**
+     * Set adminMail
+     *
+     * @param string $adminMail
+     * @return BranchSync
+     */
+    public function setAdminMail($adminMail)
+    {
+        $this->adminMail = $adminMail;
+
+        return $this;
+    }
+
+    /**
+     * Get adminMail
+     *
+     * @return string
+     */
+    public function getAdminMail()
+    {
+        return $this->adminMail;
+    }
+
+    /**
+     * Set adminName
+     *
+     * @param string $adminName
+     * @return BranchSync
+     */
+    public function setAdminName($adminName)
+    {
+        $this->adminName = $adminName;
+
+        return $this;
+    }
+
+    /**
+     * Get adminName
+     *
+     * @return string
+     */
+    public function getAdminName()
+    {
+        return $this->adminName;
+    }
+
+    /**
+     * Set adminPhone
+     *
+     * @param string $adminPhone
+     * @return BranchSync
+     */
+    public function setAdminPhone($adminPhone)
+    {
+        $this->adminPhone = $adminPhone;
+
+        return $this;
+    }
+
+    /**
+     * Get adminPhone
+     *
+     * @return string
+     */
+    public function getAdminPhone()
+    {
+        return $this->adminPhone;
+    }
+
+    /**
+     * Set lastSyncTransId
+     *
+     * @param integer $lastSyncTransId
+     * @return BranchSync
+     */
+    public function setLastSyncTransId($lastSyncTransId)
+    {
+        $this->lastSyncTransId = $lastSyncTransId;
+
+        return $this;
+    }
+
+    /**
+     * Get lastSyncTransId
+     *
+     * @return integer
+     */
+    public function getLastSyncTransId()
+    {
+        return $this->lastSyncTransId;
+    }
+
+    /**
+     * Set lastSyncTransDate
+     *
+     * @param \DateTime $lastSyncTransDate
+     * @return BranchSync
+     */
+    public function setLastSyncTransDate($lastSyncTransDate)
+    {
+        $this->lastSyncTransDate = $lastSyncTransDate;
+
+        return $this;
+    }
+
+    /**
+     * Set sslPubKey
+     *
+     * @param string $sslPubKey
+     * @return BranchSync
+     */
+    public function setSslPubKey($sslPubKey)
+    {
+        $this->sslPubKey = $sslPubKey;
+
+        return $this;
+    }
+
+    /**
+     * Get sslPubKey
+     *
+     * @return string
+     */
+    public function getSslPubKey()
+    {
+        return $this->sslPubKey;
+    }
+
+     /**
+     * Set sslPubKey
+     *
+     * @param string $sslPubKey
+     * @return BranchSync
+     */
+    public function setBranchType($branchType)
+    {
+        $this->branchType = $branchType;
+
+        return $this;
+    }
+
+    /**
+     * Get sslPubKey
+     *
+     * @return string
+     */
+    public function getBranchType()
+    {
+        return $this->branchType;
+    }
+
+    /**
+     * Get lastSyncTransDate
+     *
+     * @return \DateTime
+     */
+    public function getLastSyncTransDate()
+    {
+        return $this->lastSyncTransDate;
+    }
+
+    /**
+     * Set lastSyncType
+     *
+     * @param string $lastSyncType
+     * @return BranchSync
+     */
+    public function setLastSyncType($lastSyncType)
+    {
+        $this->lastSyncType = $lastSyncType;
+
+        return $this;
+    }
+
+    /**
+     * Get lastSyncType
+     *
+     * @return string
+     */
+    public function getLastSyncType()
+    {
+        return $this->lastSyncType;
+    }
+
+    /**
+     * Set lft
+     *
+     * @param integer $lft
+     * @return BranchSync
+     */
+    public function setLft($lft)
+    {
+        $this->lft = $lft;
+
+        return $this;
+    }
+
+    /**
+     * Get lft
+     *
+     * @return integer
+     */
+    public function getLft()
+    {
+        return $this->lft;
+    }
+
+    /**
+     * Set rgt
+     *
+     * @param integer $rgt
+     * @return BranchSync
+     */
+    public function setRgt($rgt)
+    {
+        $this->rgt = $rgt;
+
+        return $this;
+    }
+
+    /**
+     * Get rgt
+     *
+     * @return integer
+     */
+    public function getRgt()
+    {
+        return $this->rgt;
+    }
+
+    /**
+     * Set lvl
+     *
+     * @param integer $lvl
+     * @return BranchSync
+     */
+    public function setLvl($lvl)
+    {
+        $this->lvl = $lvl;
+
+        return $this;
+    }
+
+    /**
+     * Get lvl
+     *
+     * @return integer
+     */
+    public function getLvl()
+    {
+        return $this->lvl;
+    }
+
+    /**
+     * Set root
+     *
+     * @param integer $root
+     * @return BranchSync
+     */
+    public function setRoot($root)
+    {
+        $this->root = $root;
+
+        return $this;
+    }
+
+    /**
+     * Get root
+     *
+     * @return integer
+     */
+    public function getRoot()
+    {
+        return $this->root;
+    }
+
+    /**
+     * Set parentId
+     *
+     * @param integer $parentId
+     *
+     * @return BranchSync
+     */
+    public function setParentId($parentId)
+    {
+        $this->parentId = $parentId;
+
+        return $this;
+    }
+
+    /**
+     * Get parentId
+     *
+     * @return integer
+     */
+    public function getParentId()
+    {
+        return $this->parentId;
+    }
+
+    /**
+     * @param BranchSync $parent
+     *
+     * @return $this
+     */
+    public function setParent(BranchSync $parent = null)
+    {
+        $this->parent = $parent;
+
+        return $this;
+    }
+
+    /**
+     * @return mixed
+     */
+    public function getParent()
+    {
+        return $this->parent;
+    }
+
+    /**
+     * @return string
+     */
+    public function getUniqueId()
+    {
+        return $this->uniqueId;
+    }
+
+    /**
+     * @param string $uniqueId
+     *
+     * @return $this
+     */
+    public function setUniqueId($uniqueId)
+    {
+        $this->uniqueId = $uniqueId;
+
+        return $this;
+    }
+}

+ 418 - 0
src/Chamilo/CoreBundle/Entity/BranchTransaction.php

@@ -0,0 +1,418 @@
+<?php
+/* For licensing terms, see /license.txt */
+
+namespace Chamilo\CoreBundle\Entity;
+
+use Doctrine\ORM\Mapping as ORM;
+
+/**
+ * BranchTransaction
+ *
+ * @ORM\Table(name="branch_transaction")
+ * @ORM\Entity
+ */
+class BranchTransaction
+{
+    /**
+     * @var integer
+     *
+     * @ORM\Column(name="id", type="bigint", nullable=false)
+     * @ORM\Id
+     * @ORM\GeneratedValue
+     */
+    private $id;
+
+    /**
+     * @var Room
+     *
+     * @ORM\ManyToOne(targetEntity="BranchTransactionStatus")
+     * @ORM\JoinColumn(name="status_id", referencedColumnName="id")
+     **/
+    private $branchTransactionStatus;
+
+    /**
+     * @var integer
+     *
+     * @ORM\Column(name="transaction_id", type="bigint", nullable=false, unique=false)
+     */
+    private $externalTransactionId;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="action", type="string", length=20, nullable=true, unique=false)
+     */
+    private $action;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="item_id", type="string", length=255, nullable=true, unique=false)
+     */
+    private $itemId;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="origin", type="string", length=255, nullable=true, unique=false)
+     */
+    private $origin;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="dest_id", type="string", length=255, nullable=true, unique=false)
+     */
+    private $destId;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="external_info", type="string", length=255, nullable=true, unique=false)
+     */
+    private $externalInfo;
+
+    /**
+     * @var \DateTime
+     *
+     * @ORM\Column(name="time_insert", type="datetime", nullable=false, unique=false)
+     */
+    private $timeInsert;
+
+    /**
+     * @var \DateTime
+     *
+     * @ORM\Column(name="time_update", type="datetime", nullable=false, unique=false)
+     */
+    private $timeUpdate;
+
+    /**
+     * @var integer
+     *
+     * @ORM\Column(name="failed_attempts", type="integer", nullable=false, unique=false)
+     */
+    private $failedAttempts;
+
+    /**
+     * @var BranchSync
+     *
+     * @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\BranchSync")
+     * @ORM\JoinColumn(name="branch_id", referencedColumnName="id")
+     **/
+    private $branch;
+
+    /**
+     * Set id
+     *
+     * @param integer $id
+     *
+     * @return BranchTransaction
+     *
+     */
+    public function setId($id)
+    {
+        $this->id = $id;
+
+        return $this;
+    }
+
+    /**
+     * Get id
+     *
+     * @return integer
+     */
+    public function getId()
+    {
+        return $this->id;
+    }
+
+    /**
+     * Set transactionId
+     *
+     * @param integer $transactionId
+     *
+     * @return BranchTransaction
+     */
+    public function setTransactionId($transactionId)
+    {
+        $this->transactionId = $transactionId;
+
+        return $this;
+    }
+
+    /**
+     * Get transactionId
+     *
+     * @return integer
+     */
+    public function getTransactionId()
+    {
+        return $this->transactionId;
+    }
+
+    /**
+     * Set branchId
+     *
+     * @param integer $branchId
+     *
+     * @return BranchTransaction
+     */
+    public function setBranchId($branchId)
+    {
+        $this->branchId = $branchId;
+
+        return $this;
+    }
+
+    /**
+     * Get branchId
+     *
+     * @return integer
+     */
+    public function getBranchId()
+    {
+        return $this->branchId;
+    }
+
+    /**
+     * Set action
+     *
+     * @param string $action
+     *
+     * @return BranchTransaction
+     */
+    public function setAction($action)
+    {
+        $this->action = $action;
+
+        return $this;
+    }
+
+    /**
+     * Get action
+     *
+     * @return string
+     */
+    public function getAction()
+    {
+        return $this->action;
+    }
+
+    /**
+     * Set itemId
+     *
+     * @param string $itemId
+     *
+     * @return BranchTransaction
+     */
+    public function setItemId($itemId)
+    {
+        $this->itemId = $itemId;
+
+        return $this;
+    }
+
+    /**
+     * Get itemId
+     *
+     * @return string
+     */
+    public function getItemId()
+    {
+        return $this->itemId;
+    }
+
+    /**
+     * Set destId
+     *
+     * @param string $destId
+     *
+     * @return BranchTransaction
+     */
+    public function setDestId($destId)
+    {
+        $this->destId = $destId;
+
+        return $this;
+    }
+
+    /**
+     * Get destId
+     *
+     * @return string
+     */
+    public function getDestId()
+    {
+        return $this->destId;
+    }
+
+    /**
+     * Set timeInsert
+     *
+     * @param \DateTime $timeInsert
+     *
+     * @return BranchTransaction
+     */
+    public function setTimeInsert($timeInsert)
+    {
+        $this->timeInsert = $timeInsert;
+
+        return $this;
+    }
+
+    /**
+     * Get timeInsert
+     *
+     * @return \DateTime
+     */
+    public function getTimeInsert()
+    {
+        return $this->timeInsert;
+    }
+
+    /**
+     * Set timeUpdate
+     *
+     * @param \DateTime $timeUpdate
+     *
+     * @return BranchTransaction
+     */
+    public function setTimeUpdate($timeUpdate)
+    {
+        $this->timeUpdate = $timeUpdate;
+
+        return $this;
+    }
+
+    /**
+     * Get timeUpdate
+     *
+     * @return \DateTime
+     */
+    public function getTimeUpdate()
+    {
+        return $this->timeUpdate;
+    }
+
+    /**
+     * @return string
+     */
+    public function getOrigin()
+    {
+        return $this->origin;
+    }
+
+    /**
+     * @param string $origin
+     *
+     * @return BranchTransaction
+     */
+    public function setOrigin($origin)
+    {
+        $this->origin = $origin;
+
+        return $this;
+    }
+
+    /**
+     * @return string
+     */
+    public function getExternalInfo()
+    {
+        return $this->externalInfo;
+    }
+
+    /**
+     * @param string $externalInfo
+     *
+     * @return BranchTransaction
+     */
+    public function setExternalInfo($externalInfo)
+    {
+        $this->externalInfo = $externalInfo;
+
+        return $this;
+    }
+
+    /**
+     * @return int
+     */
+    public function getFailedAttempts()
+    {
+        return $this->failedAttempts;
+    }
+
+    /**
+     * @param int $failedAttempts
+     *
+     * @return BranchTransaction
+     */
+    public function setFailedAttempts($failedAttempts)
+    {
+        $this->failedAttempts = $failedAttempts;
+
+        return $this;
+    }
+
+    /**
+     * @return BranchSync
+     */
+    public function getBranch()
+    {
+        return $this->branch;
+    }
+
+    /**
+     * @param BranchSync $branch
+     *
+     * @return $this
+     */
+    public function setBranch($branch)
+    {
+        $this->branch = $branch;
+
+        return $this;
+    }
+
+    /**
+     * @return Room
+     */
+    public function getBranchTransactionStatus()
+    {
+        return $this->branchTransactionStatus;
+    }
+
+    /**
+     * @param Room $branchTransactionStatus
+     * @return BranchTransaction
+     */
+    public function setBranchTransactionStatus($branchTransactionStatus)
+    {
+        $this->branchTransactionStatus = $branchTransactionStatus;
+
+        return $this;
+    }
+
+    /**
+     * @return int
+     */
+    public function getExternalTransactionId()
+    {
+        return $this->externalTransactionId;
+    }
+
+    /**
+     * @param int $externalTransactionId
+     * @return BranchTransaction
+     */
+    public function setExternalTransactionId($externalTransactionId)
+    {
+        $this->externalTransactionId = $externalTransactionId;
+
+        return $this;
+    }
+
+
+
+
+}

+ 64 - 0
src/Chamilo/CoreBundle/Entity/BranchTransactionStatus.php

@@ -0,0 +1,64 @@
+<?php
+/* For licensing terms, see /license.txt */
+
+namespace Chamilo\CoreBundle\Entity;
+
+use Doctrine\ORM\Mapping as ORM;
+
+/**
+ * BranchTransactionStatus
+ *
+ * @ORM\Table(name="branch_transaction_status")
+ * @ORM\Entity
+ */
+class BranchTransactionStatus
+{
+    /**
+     * @var integer
+     *
+     * @ORM\Column(name="id", type="integer", nullable=false, unique=false)
+     * @ORM\Id
+     * @ORM\GeneratedValue
+     */
+    private $id;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="title", type="string", length=255, nullable=true, unique=false)
+     */
+    private $title;
+
+    /**
+     * Get id
+     *
+     * @return integer
+     */
+    public function getId()
+    {
+        return $this->id;
+    }
+
+    /**
+     * Set title
+     *
+     * @param string $title
+     * @return BranchTransactionStatus
+     */
+    public function setTitle($title)
+    {
+        $this->title = $title;
+
+        return $this;
+    }
+
+    /**
+     * Get title
+     *
+     * @return string
+     */
+    public function getTitle()
+    {
+        return $this->title;
+    }
+}

+ 28 - 1
src/Chamilo/CoreBundle/Entity/Course.php

@@ -264,13 +264,21 @@ class Course
      **/
     //protected $curriculumCategories;
 
+    /**
+     * @var Room
+     *
+     * @ORM\ManyToOne(targetEntity="Room")
+     * @ORM\JoinColumn(name="room_id", referencedColumnName="id")
+     **/
+    private $room;
+
     /**
      * @var Session
      **/
     protected $currentSession;
 
     /**
-     *
+     * Constructor
      */
     public function __construct()
     {
@@ -1111,6 +1119,25 @@ class Course
         return $this->courseTypeId;
     }
 
+    /**
+     * @return Room
+     */
+    public function getRoom()
+    {
+        return $this->room;
+    }
+
+    /**
+     * @param Room $room
+     * @return Course
+     */
+    public function setRoom($room)
+    {
+        $this->room = $room;
+
+        return $this;
+    }
+
     /**
      * @return string
      */

+ 37 - 0
src/Chamilo/CoreBundle/Entity/Repository/BranchSyncRepository.php

@@ -0,0 +1,37 @@
+<?php
+/* For licensing terms, see /license.txt */
+
+namespace Chamilo\CoreBundle\Entity\Repository;
+
+use Gedmo\Tree\Entity\Repository\NestedTreeRepository;
+
+/**
+ * Class BranchSyncRepository
+ * @package Chamilo\CoreBundle\Entity\Repository
+ */
+class BranchSyncRepository extends NestedTreeRepository
+{
+    /**
+     * @param string $keyword
+     * @return mixed
+     */
+    public function searchByKeyword($keyword)
+    {
+        $qb = $this->createQueryBuilder('a');
+
+        //Selecting user info
+        $qb->select('DISTINCT b');
+
+        $qb->from('Chamilo\CoreBundle\Entity\BranchSync', 'b');
+
+        //Selecting courses for users
+        //$qb->innerJoin('u.courses', 'c');
+
+        //@todo check app settings
+        $qb->add('orderBy', 'b.branchName ASC');
+        $qb->where('b.branchName LIKE :keyword');
+        $qb->setParameter('keyword', "%$keyword%");
+        $q = $qb->getQuery();
+        return $q->execute();
+    }
+}

+ 199 - 0
src/Chamilo/CoreBundle/Entity/Room.php

@@ -0,0 +1,199 @@
+<?php
+/* For licensing terms, see /license.txt */
+
+namespace Chamilo\CoreBundle\Entity;
+
+use Doctrine\ORM\Mapping as ORM;
+
+/**
+ * Room
+ *
+ * @ORM\Table(name="room")
+ * @ORM\Entity
+ */
+class Room
+{
+    /**
+     * @var integer
+     *
+     * @ORM\Column(name="id", type="integer", nullable=false, unique=false)
+     * @ORM\Id
+     * @ORM\GeneratedValue
+     */
+    private $id;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="title", type="string", length=255, nullable=true, unique=false)
+     */
+    private $title;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="description", type="text", nullable=true)
+     */
+    private $description;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="geolocation", type="string", length=255, nullable=true, unique=false)
+     */
+    private $geolocation;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="ip", type="string", length=39, nullable=true, unique=false)
+     */
+    private $ip;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="ip_mask", type="string", length=6, nullable=true, unique=false)
+     */
+    private $ipMask;
+
+    /**
+     * @var BranchSync
+     *
+     * @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\BranchSync")
+     * @ORM\JoinColumn(name="branch_id", referencedColumnName="id")
+     **/
+    private $branch;
+
+    /**
+     * Get id
+     *
+     * @return integer
+     */
+    public function getId()
+    {
+        return $this->id;
+    }
+
+    /**
+     * Set title
+     *
+     * @param string $title
+     *
+     * @return $this
+     */
+    public function setTitle($title)
+    {
+        $this->title = $title;
+
+        return $this;
+    }
+
+    /**
+     * Get title
+     *
+     * @return string
+     */
+    public function getTitle()
+    {
+        return $this->title;
+    }
+
+    /**
+     * @return string
+     */
+    public function getDescription()
+    {
+        return $this->description;
+    }
+
+    /**
+     * @param string $description
+     * @return Room
+     */
+    public function setDescription($description)
+    {
+        $this->description = $description;
+
+        return $this;
+    }
+
+    /**
+     * @return string
+     */
+    public function getGeolocation()
+    {
+        return $this->geolocation;
+    }
+
+    /**
+     * @param string $geolocation
+     * @return Room
+     */
+    public function setGeolocation($geolocation)
+    {
+        $this->geolocation = $geolocation;
+
+        return $this;
+    }
+
+    /**
+     * @return string
+     */
+    public function getIp()
+    {
+        return $this->ip;
+    }
+
+    /**
+     * @param string $ip
+     *
+     * @return Room
+     */
+    public function setIp($ip)
+    {
+        $this->ip = $ip;
+
+        return $this;
+    }
+
+    /**
+     * @return string
+     */
+    public function getIpMask()
+    {
+        return $this->ipMask;
+    }
+
+    /**
+     * @param string $ipMask
+     *
+     * @return Room
+     */
+    public function setIpMask($ipMask)
+    {
+        $this->ipMask = $ipMask;
+
+        return $this;
+    }
+
+    /**
+     * @return BranchSync
+     */
+    public function getBranch()
+    {
+        return $this->branch;
+    }
+
+    /**
+     * @param BranchSync $branch
+     *
+     * @return $this
+     */
+    public function setBranch($branch)
+    {
+        $this->branch = $branch;
+
+        return $this;
+    }
+}

+ 68 - 0
src/Chamilo/CoreBundle/Migrations/Schema/V110/Version20150603142550.php

@@ -0,0 +1,68 @@
+<?php
+
+namespace ;
+
+use Doctrine\DBAL\Migrations\AbstractMigration;
+use Doctrine\DBAL\Schema\Schema;
+
+/**
+ * Auto-generated Migration: Please modify to your needs!
+ */
+class Version20150603142550 extends AbstractMigration
+{
+    /**
+     * @param Schema $schema
+     */
+    public function up(Schema $schema)
+    {
+        // this up() migration is auto-generated, please modify it to your needs
+        $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+
+        $this->addSql('CREATE TABLE room (id INT AUTO_INCREMENT NOT NULL, branch_id INT DEFAULT NULL, title VARCHAR(255) DEFAULT NULL, description LONGTEXT DEFAULT NULL, geolocation VARCHAR(255) DEFAULT NULL, ip VARCHAR(39) DEFAULT NULL, ip_mask VARCHAR(6) DEFAULT NULL, INDEX IDX_729F519BDCD6CC49 (branch_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
+        $this->addSql('CREATE TABLE branch_transaction_status (id INT AUTO_INCREMENT NOT NULL, title VARCHAR(255) DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
+        $this->addSql('CREATE TABLE branch_transaction (id BIGINT AUTO_INCREMENT NOT NULL, status_id INT DEFAULT NULL, branch_id INT DEFAULT NULL, transaction_id BIGINT NOT NULL, action VARCHAR(20) DEFAULT NULL, item_id VARCHAR(255) DEFAULT NULL, origin VARCHAR(255) DEFAULT NULL, dest_id VARCHAR(255) DEFAULT NULL, external_info VARCHAR(255) DEFAULT NULL, time_insert DATETIME NOT NULL, time_update DATETIME NOT NULL, failed_attempts INT NOT NULL, INDEX IDX_FEFBA12B6BF700BD (status_id), INDEX IDX_FEFBA12BDCD6CC49 (branch_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
+        $this->addSql('CREATE TABLE branch_sync (id INT AUTO_INCREMENT NOT NULL, parent_id INT DEFAULT NULL, access_url_id INT NOT NULL, unique_id VARCHAR(50) NOT NULL, branch_name VARCHAR(250) NOT NULL, description LONGTEXT DEFAULT NULL, branch_ip VARCHAR(40) DEFAULT NULL, latitude NUMERIC(10, 0) DEFAULT NULL, longitude NUMERIC(10, 0) DEFAULT NULL, dwn_speed INT DEFAULT NULL, up_speed INT DEFAULT NULL, delay INT DEFAULT NULL, admin_mail VARCHAR(250) DEFAULT NULL, admin_name VARCHAR(250) DEFAULT NULL, admin_phone VARCHAR(250) DEFAULT NULL, last_sync_trans_id BIGINT DEFAULT NULL, last_sync_trans_date DATETIME DEFAULT NULL, last_sync_type VARCHAR(20) DEFAULT NULL, ssl_pub_key VARCHAR(250) DEFAULT NULL, branch_type VARCHAR(250) DEFAULT NULL, lft INT DEFAULT NULL, rgt INT DEFAULT NULL, lvl INT DEFAULT NULL, root INT DEFAULT NULL, UNIQUE INDEX UNIQ_F62F45EDE3C68343 (unique_id), INDEX IDX_F62F45ED727ACA70 (parent_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
+        $this->addSql('ALTER TABLE room ADD CONSTRAINT FK_729F519BDCD6CC49 FOREIGN KEY (branch_id) REFERENCES branch_sync (id)');
+        $this->addSql('ALTER TABLE branch_transaction ADD CONSTRAINT FK_FEFBA12B6BF700BD FOREIGN KEY (status_id) REFERENCES branch_transaction_status (id)');
+        $this->addSql('ALTER TABLE branch_transaction ADD CONSTRAINT FK_FEFBA12BDCD6CC49 FOREIGN KEY (branch_id) REFERENCES branch_sync (id)');
+        $this->addSql('ALTER TABLE branch_sync ADD CONSTRAINT FK_F62F45ED727ACA70 FOREIGN KEY (parent_id) REFERENCES branch_sync (id) ON DELETE SET NULL');
+        $this->addSql('ALTER TABLE course ADD room_id INT DEFAULT NULL');
+        $this->addSql('ALTER TABLE course ADD CONSTRAINT FK_169E6FB954177093 FOREIGN KEY (room_id) REFERENCES room (id)');
+        $this->addSql('CREATE INDEX IDX_169E6FB954177093 ON course (room_id)');
+        $this->addSql('ALTER TABLE session DROP date_start, DROP date_end, DROP nb_days_access_before_beginning, DROP nb_days_access_after_end');
+        $this->addSql('ALTER TABLE c_calendar_event ADD room_id INT DEFAULT NULL');
+        $this->addSql('ALTER TABLE c_calendar_event ADD CONSTRAINT FK_A062258154177093 FOREIGN KEY (room_id) REFERENCES room (id)');
+        $this->addSql('CREATE INDEX IDX_A062258154177093 ON c_calendar_event (room_id)');
+        $this->addSql('ALTER TABLE c_thematic_advance ADD room_id INT DEFAULT NULL');
+        $this->addSql('ALTER TABLE c_thematic_advance ADD CONSTRAINT FK_62798E9754177093 FOREIGN KEY (room_id) REFERENCES room (id)');
+        $this->addSql('CREATE INDEX IDX_62798E9754177093 ON c_thematic_advance (room_id)');
+    }
+
+    /**
+     * @param Schema $schema
+     */
+    public function down(Schema $schema)
+    {
+        // this down() migration is auto-generated, please modify it to your needs
+        $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+
+        $this->addSql('ALTER TABLE course DROP FOREIGN KEY FK_169E6FB954177093');
+        $this->addSql('ALTER TABLE c_calendar_event DROP FOREIGN KEY FK_A062258154177093');
+        $this->addSql('ALTER TABLE c_thematic_advance DROP FOREIGN KEY FK_62798E9754177093');
+        $this->addSql('ALTER TABLE branch_transaction DROP FOREIGN KEY FK_FEFBA12B6BF700BD');
+        $this->addSql('ALTER TABLE room DROP FOREIGN KEY FK_729F519BDCD6CC49');
+        $this->addSql('ALTER TABLE branch_transaction DROP FOREIGN KEY FK_FEFBA12BDCD6CC49');
+        $this->addSql('ALTER TABLE branch_sync DROP FOREIGN KEY FK_F62F45ED727ACA70');
+        $this->addSql('DROP TABLE room');
+        $this->addSql('DROP TABLE branch_transaction_status');
+        $this->addSql('DROP TABLE branch_transaction');
+        $this->addSql('DROP TABLE branch_sync');
+        $this->addSql('DROP INDEX IDX_A062258154177093 ON c_calendar_event');
+        $this->addSql('ALTER TABLE c_calendar_event DROP room_id');
+        $this->addSql('DROP INDEX IDX_62798E9754177093 ON c_thematic_advance');
+        $this->addSql('ALTER TABLE c_thematic_advance DROP room_id');
+        $this->addSql('DROP INDEX IDX_169E6FB954177093 ON course');
+        $this->addSql('ALTER TABLE course DROP room_id');
+        $this->addSql('ALTER TABLE session ADD date_start DATE NOT NULL, ADD date_end DATE NOT NULL, ADD nb_days_access_before_beginning TINYINT(1) DEFAULT NULL, ADD nb_days_access_after_end TINYINT(1) DEFAULT NULL');
+    }
+}

+ 27 - 0
src/Chamilo/CourseBundle/Entity/CCalendarEvent.php

@@ -91,6 +91,14 @@ class CCalendarEvent
      */
     private $comment;
 
+    /**
+     * @var Room
+     *
+     * @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\Room")
+     * @ORM\JoinColumn(name="room_id", referencedColumnName="id")
+     **/
+    private $room;
+
     /**
      * Set title
      *
@@ -318,5 +326,24 @@ class CCalendarEvent
         return $this;
     }
 
+    /**
+     * @return Room
+     */
+    public function getRoom()
+    {
+        return $this->room;
+    }
+
+    /**
+     * @param Room $room
+     * @return $this
+     */
+    public function setRoom($room)
+    {
+        $this->room = $room;
+
+        return $this;
+    }
+
 
 }

+ 28 - 0
src/Chamilo/CourseBundle/Entity/CThematicAdvance.php

@@ -78,6 +78,14 @@ class CThematicAdvance
      */
     private $doneAdvance;
 
+    /**
+     * @var Room
+     *
+     * @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\Room")
+     * @ORM\JoinColumn(name="room_id", referencedColumnName="id")
+     **/
+    private $room;
+
     /**
      * Set thematicId
      *
@@ -261,4 +269,24 @@ class CThematicAdvance
     {
         return $this->cId;
     }
+
+    /**
+     * @return Room
+     */
+    public function getRoom()
+    {
+        return $this->room;
+    }
+
+    /**
+     * @param Room $room
+     *
+     * @return $this
+     */
+    public function setRoom($room)
+    {
+        $this->room = $room;
+
+        return $this;
+    }
 }