✏️ 正在编辑: CallcenterMotivosPausa.php
路径:
/srv/systems_dir/yuppiecred-bkp/application/models/CallcenterMotivosPausa.php
提示:
您可以编辑任何文件(包括二进制文件),但请注意不当修改可能导致文件损坏。
<?php class Model_CallcenterMotivosPausa { private $_id; private $_descricao; private $_codigo; private $_tempoLimitePausa; private $_toleranciaPausa; public $dbTable; public function getId() { return $this->_id; } public function setId($id) { $this->_id = $id; } public function getDescricao() { return $this->_descricao; } public function setDescricao($descricao) { $this->_descricao = $descricao; } public function getCodigo() { return $this->_codigo; } public function setCodigo($codigo) { $this->_codigo = $codigo; } public function setPausaYuppie($pausa) { $this->_pausaYuppie = $pausa; } public function getPausaYuppie() { return $this->_pausaYuppie; } public function setPausaDiscador($pausa) { $this->_pausaDiscador = $pausa; } public function getPausaDiscador() { return $this->_pausaDiscador; } public function setTempoLimitePausa($tempoLimitePausa) { if ($tempoLimitePausa) $this->_tempoLimitePausa = $tempoLimitePausa * 60; } public function getTempoLimitePausa() { return $this->_tempoLimitePausa; } public function setToleranciaPausa($toleranciaPausa) { if ($toleranciaPausa) $this->_toleranciaPausa = $toleranciaPausa * 60; } public function getToleranciaPausa() { return $this->_toleranciaPausa; } public function setLogoutDiscador($logout) { $this->_logoutDiscador = $logout; } public function getLogoutDiscador() { return $this->_logoutDiscador; } public function __construct($options = null) { $this->dbTable = new Model_DbTable_CallcenterMotivoPausa; if( is_array($options) ){ $this->setOptions($options); } } public function setOptions(array $options) { $methods = get_class_methods($this); foreach ( $options as $key => $value ) { $explode = explode("_", $key); $methodName = ''; foreach ( $explode as $v ) { $methodName .= ucfirst($v); } $key = $methodName != '' ? $methodName : $key; $method = 'set' . ucfirst($key); if( in_array($method, $methods) ){ $this->$method($value); } } return $this; } public function _toArray() { $dbtable = $this->dbTable; $info = $dbtable->info(); $methods = get_class_methods($this); $data = array( ); foreach ( $info['cols'] as $key ) { $col = $key; $explode = explode("_", $key); $methodName = ''; foreach ( $explode as $v ) { $methodName .= ucfirst($v); } $key = $methodName != '' ? $methodName : $key; $method = 'get' . ucfirst($key); if( in_array($method, $methods) ){ $data[$col] = $this->$method(); } } return $data; } /** * Insere ou altera o registro passado por parâmetro * @param Model_CallcenterMotivosPausa $statusCampanha */ public function salvar(Model_CallcenterMotivosPausa $motivosPausa) { if ($motivosPausa->getId() > 0) { $this->dbTable->update($motivosPausa->_toArray(), "id = " . $motivosPausa->getId()); return $motivosPausa->getId(); } else { return $this->dbTable->insert($motivosPausa->_toArray()); } } /** * Exclui o registro passado por parâmetro * @param int $id * @return int The number of rows deleted */ public function excluir($id) { if ($id > 0) { return $this->dbTable->delete("id = " . $id); } return null; } /** * Retorna uma lista * @param string $where * @param string $order * @param int $count * @param int $offset * @return array */ public function listar($where = null, $order = "descricao ASC", $count = null, $offset = null) { return $this->dbTable->fetchAll($where, $order, $count, $offset); } /** * Retorna um fetchRow do item passado por parâmetro * @param int $id * @return Zend_Db_Table_Row_Abstract | null */ public function exibir($id) { $dados = $this->dbTable->fetchRow(["id = ?" => $id]); $dados->tempo_limite_pausa = $dados->tempo_limite_pausa / 60; $dados->tolerancia_pausa = $dados->tolerancia_pausa / 60; return $dados; } public function checarTempoPausa() { if( !Yuppie_Auth::getIdentity() ){ return true; } $pausasOperadores = new Model_DbTable_CallcenterPausaOperador(); $ultimaPausa = $pausasOperadores->fetchRow([ 'operador = ?' => Yuppie_Auth::getIdentity()->nome, 'acao = ?' => 'pausar', ], 'id DESC'); if (empty($ultimaPausa)) return true; $motivo = (new Model_DbTable_CallcenterMotivoPausa)->fetchRow(['descricao = ?' => $ultimaPausa->motivo_acao]); if (empty($motivo)) return true; if ($motivo->logout_discador) return true; $tempo = strtotime(Zend_Date::now()->get("yyyy-MM-dd HH:mm:ss")) - strtotime($ultimaPausa->data_hora_acao); if ($motivo->tempo_limite_pausa) { $pausa = $motivo->tempo_limite_pausa + $motivo->tolerancia_pausa; if (Model_Usuario::checarPermissaoRetornoPausa(Yuppie_Auth::getIdentity()->grupo) == false && $tempo > $pausa) { return [ 'result' => false, 'msg' => 'O tempo para retorno da pausa foi ultrapassado. Solicite autorização.' ]; } } return true; } }
💾 保存文件
← 返回文件管理器