_init('aw_hdu3/department'); } /** * @return AW_Helpdesk3_Model_Department_Notification */ public function getEmailNotification() { return Mage::getModel('aw_hdu3/department_notification')->loadByDepartmentId($this->getId()); } /** * @return AW_Helpdesk3_Model_Department_Permission */ public function getPermission() { return Mage::getModel('aw_hdu3/department_permission')->loadByDepartmentId($this->getId()); } /** * @return AW_Helpdesk3_Model_Resource_Department_Agent_Collection */ public function getAgentCollection() { $agentCollection = Mage::getModel('aw_hdu3/department_agent')->getCollection()->addNotDeletedFilter(); $agentCollection->addFilterByDepartmentId($this->getId()); return $agentCollection; } public function getPrimaryAgent() { $agent = Mage::getModel('aw_hdu3/department_agent')->load($this->getPrimaryAgentId()); $agent->setDepartment($this); return $agent; } /** * @param Mage_Admin_Model_User $user * * @return bool */ public function isCanViewTicket($user) { return $this->getPermission()->isCanViewTicket($user); } /** * @return AW_Helpdesk3_Model_Gateway */ public function getGateway() { return Mage::getModel('aw_hdu3/gateway')->loadByDepartmentId($this->getId()); } /** * @param array $agentIds * * @return $this */ public function addDepartmentAgents($agentIds) { $this->getResource()->addDepartmentAgents($this, $agentIds); return $this; } public function isEnabled() { return ($this->getStatus() == AW_Helpdesk3_Model_Source_Status::ENABLED_VALUE); } public function isPrimary() { return ($this->getId() == Mage::helper('aw_hdu3/config')->getDefaultDepartmentId(Mage::app()->getStore()->getId())); } /** * @return $this */ protected function _beforeSave() { $_result = parent::_beforeSave(); if ($this->isObjectNew()) { $currentDate = new Zend_Date(); $this ->setCreatedAt($currentDate->toString(Varien_Date::DATETIME_INTERNAL_FORMAT)) ; } return $_result; } }