✏️ 正在编辑: CallcenterPausasProgramadas.php
路径:
/srv/systems_dir/yuppiecred/application/models/CallcenterPausasProgramadas.php
提示:
您可以编辑任何文件(包括二进制文件),但请注意不当修改可能导致文件损坏。
<?php class Model_CallcenterPausasProgramadas { private $_id; private $_usuarioId; private $_horaPausa; private $_motivoId; public $dbTable; public function getId() { return $this->_id; } public function setId($id) { $this->_id = $id; } public function getUsuarioId() { return $this->_usuarioId; } public function setUsuarioId($usuarioId) { $this->_usuarioId = $usuarioId; } public function getHoraPausa() { return $this->_horaPausa; } public function setHoraPausa($horaPausa) { $hora = explode(':', $horaPausa); $totalMinutos = ($hora[0] * 60) + $hora[1]; $this->_horaPausa = $totalMinutos; } public function getMotivoId() { return $this->_motivoId; } public function setMotivoId($motivoId) { $this->_motivoId = $motivoId; } public function __construct($options = null) { $this->dbTable = new Model_DbTable_CallcenterPausasProgramadas(); 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 = []; 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; } public function salvar(Model_CallcenterPausasProgramadas $pausas) { $dbtable = new Model_DbTable_CallcenterPausasProgramadas(); $result = false; $dadosPausa = $pausas->_toArray(); if( is_array($pausas->_usuarioId) ){ $result = $this->_multiSave($pausas, $dadosPausa); }else{ if ($pausas->getId() > 0) { $result = $dbtable->update($dadosPausa, ["id = ?" => $pausas->getId()]); } else { $result = $dbtable->insert($dadosPausa); } } return $result; } protected function _multiSave($pausas, $dadosPausa) { $cont = 0; foreach( $pausas->_usuarioId as $usuarioId ){ unset($dadosPausa['usuario_id']); $dadosPausa['usuario_id'] = $usuarioId; $dbtable = new Model_DbTable_CallcenterPausasProgramadas(); if ($pausas->getId() > 0) { if( $dbtable->update($dadosPausa, ["id = ?" => $pausas->getId()]) ){ $cont++; } } elseif( $dbtable->insert($dadosPausa) ) { $cont++; } } return $cont; } public function excluir($id) { if ($id > 0) { return $this->dbTable->delete("id = " . $id); } return null; } public function listar($where = null, $order = "descricao ASC", $count = null, $offset = null) { return $this->dbTable->fetchAll($where, $order, $count, $offset); } public function exibir($id) { $dados = $this->dbTable->fetchRow(["id = ?" => $id]); $dados->hora_pausa = Zend_Date::now()->setTime(0)->setMinute($dados->hora_pausa)->get('HH:mm'); return $dados; } public function verificarPausaProgramada() { $horaAtual = explode(':', Zend_Date::now()->get("HH:mm")); $totalMinutosAtual = ($horaAtual[0] * 60) + $horaAtual[1]; $tabelaPausasProgramadas = new Model_DbTable_CallcenterPausasProgramadas(); $pausasProgramadas = $tabelaPausasProgramadas->fetchAll(['usuario_id = ?' => Yuppie_Auth::getIdentity()->id]); foreach ($pausasProgramadas as $pausa) { if ($totalMinutosAtual < ($pausa->hora_pausa - 3) || $totalMinutosAtual > $pausa->hora_pausa) continue; if (!$class = Core_Discador_Factory::load()) return false; $motivoPausa = current((new Model_DbTable_CallcenterMotivoPausa) ->find($pausa['motivo_id'])->toArray()); if (Model_CallcenterOperador::deslogarDiscador($motivoPausa) == "1") return true; } } }
💾 保存文件
← 返回文件管理器