✏️ 正在编辑: CallcenterTelefone.php
路径:
/srv/systems_dir/yuppiecred-bkp/application/models/CallcenterTelefone.php
提示:
您可以编辑任何文件(包括二进制文件),但请注意不当修改可能导致文件损坏。
<?php class Model_CallcenterTelefone { private $_id; private $_clienteId; private $_cpfCliente; private $_fone; private $_obs; private $_whatsapp; public function getId() { return $this->_id; } public function setId($id) { $this->_id = $id; } public function getClienteId() { return $this->_clienteId; } public function getCpfCliente() { return $this->_cpfCliente; } function setCpfCliente($cpfCliente): void { $this->_cpfCliente = $cpfCliente; } public function setClienteId($clienteId) { $this->_clienteId = $clienteId; } public function getFone() { return $this->_fone; } public function setFone($fone) { $this->_fone = $fone; } public function getObs() { return $this->_obs; } public function setObs($obs) { $this->_obs = $obs; } public function getWhatsapp() { return $this->_whatsapp; } public function setWhatsapp($whatsapp) { $this->_whatsapp = $whatsapp; } public function __construct($options = null) { 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 = new Model_DbTable_CallcenterTelefone(); $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; } public function salvar() { $dbtable = new Model_DbTable_CallcenterTelefone(); if( $this->getId() > 0 ){ $dbtable->update($this->_toArray(), "id = " . $this->getId()); return $this->getId(); } else { return $dbtable->insert($this->_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 ){ $dbtable = new Model_DbTable_CallcenterTelefone(); return $dbtable->delete("id = " . $id); } return null; } /** * Retorna uma lista * @param string $where * @param string $order * @return array */ public function listar($fields = null, $order = "id ASC") { $where = null; $params = array(); if( !empty($fields['cliente_id']) ){ $params[] = "cliente_id = " . $fields['cliente_id']; } if( count($params) > 0 ){ $where = implode(' AND ', $params); $dbtable = new Model_DbTable_CallcenterTelefone(); return $dbtable->fetchAll($where, $order); } return null; } public function exibir($id) { $dbtable = new Model_DbTable_CallcenterTelefone(); return $dbtable->fetchRow("id = " . $id); } public function temTelefone($clienteId) { $dbTelefone = new Model_DbTable_CallcenterTelefone(); if( $dbTelefone->fetchRow("cliente_id = " . $clienteId) != null){ return true; } return false; } public static function existeOuCria($cpf, $fone) { $cpf = String_Refatorar::formatarCpf($cpf); $registro = (new Model_DbTable_CallcenterTelefone)->fetchRow(["cpf_cliente" => $cpf, "fone = ?" => $fone]); if ($registro){ return new self($registro->toArray()); } return new self; } public static function attDiscadorDescartar($telefoneId, $acao) { $result = ['status' => false]; $dbTelefone = new Model_DbTable_CallcenterTelefone(); $updated = $dbTelefone->update([ 'discador_descartar' => $acao == 'ativar' ? 0 : 1, ], ['id = ?' => $telefoneId]); if ($updated) { $result['status'] = true; } return $result; } public static function setarWhatsapp($telefoneId, $acao) { $result = ['status' => false]; $dbTelefone = new Model_DbTable_CallcenterTelefone(); $updated = $dbTelefone->update([ 'whatsapp' => $acao == 'ativar' ? 1 : 0, ], ['id = ?' => $telefoneId]); if ($updated) { $result['status'] = true; } return $result; } public static function atualizarNaoPerturbe($telefoneId, $acao) { $result = ['status' => false]; $dbTelefone = new Model_DbTable_CallcenterTelefone(); $updated = $dbTelefone->update([ 'nao_perturbe' => $acao == 'bloquear' ? 1 : 0, ], ['id = ?' => $telefoneId]); if ($updated) { $result['status'] = true; } $dados = $dbTelefone->fetchRow(['id = ?' => $telefoneId]); $modelBlacklist = new Model_BlacklistNaoPerturbe(); $modelBlacklist->salvar([ 'telefone' => $dados['fone'], 'cpf' => $dados['cpf_cliente'], 'banco' => 'TODOS', 'excluido' => $acao == 'bloquear' ? 0 : 1 ]); return $result; } public function excluirTelefonesBase($baseId) { if(empty($baseId)){ return; } $dbTelefone = new Model_DbTable_CallcenterTelefone(); return $dbTelefone->update(['excluido' => 1], ["cliente_id = ?" => $baseId]); } }
💾 保存文件
← 返回文件管理器