forked from SimplesIP/pabx-app
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
85 lines
2.6 KiB
85 lines
2.6 KiB
<?php |
|
|
|
/* |
|
* To change this template, choose Tools | Templates |
|
* and open the template in the editor. |
|
*/ |
|
|
|
class Error { |
|
|
|
public function __construct($login) { |
|
$this->login = $login; |
|
} |
|
|
|
public function SetLogin($login) { |
|
$this->login = $login; |
|
} |
|
|
|
public function GetPhpError($funcName = "", $dispMsg = "", $msgSistem = "") { |
|
//captura os erros gerados pelo php |
|
$er = ''; //error_get_last(); |
|
if (($er) && (!empty($er[self::ERROR_MESSAGE]))) { |
|
foreach ($er as $key => $value) |
|
$this->error[$key] = $value; |
|
|
|
//Nome da funcao que gerou o erro |
|
$this->error[self::ERROR_FUNC_NAME] = !$funcName ? basename($this->error[self::ERROR_FILE]) : $funcName; |
|
|
|
//Usuario logado na aplicacao |
|
$this->error[self::LOGIN_ON] = $this->login; |
|
|
|
//Mensagem adicional gerado pelo sistema |
|
$this->error[self::ERROR_MSG_SYSTEM] = $msgSistem; |
|
|
|
//Display para o usuario |
|
$this->error[self::ERROR_MSG_DISPLAY] = $dispMsg ? $dispMsg . " " . $this->error[self::ERROR_MESSAGE] : "A operação não pode ser realizada! " . $this->error[self::ERROR_MESSAGE]; |
|
|
|
//Mensagem do sistema |
|
$this->error[self::LOGIN_ON] = $this->login; |
|
|
|
//Armazena todos os erros gerados |
|
$this->errors[] = $this->error; |
|
} |
|
} |
|
|
|
function ClearErros() { |
|
@trigger_error(""); |
|
} |
|
|
|
/* |
|
* Retorna número de erros gerados |
|
*/ |
|
|
|
function GetNumError() { |
|
return count($this->errors); |
|
} |
|
|
|
function DisplayError() { |
|
$i = 0; |
|
$tb = "<table align=\"center\" class=\"error\" border=\"0\" cellspacing=\"0\" cellpadding=\"2\">\n"; |
|
$tb .= "<tr ><td class=\"error_head\">A Operação não pode ser realizada! Erro(s):</td><td class=\"error_head\" style=\"text-align:right\" align=\"right\" ><img src=\"imgsite\error.png\" border=\"0\" width=\"16\" height=\"16\"></td></tr>\n"; |
|
foreach ($this->errors as $value) |
|
$tb .= "<tr><td colspan=2 class=\"error_td\">" . $value[self::ERROR_MSG_DISPLAY] . "</td></tr>\n"; |
|
|
|
|
|
$tb .= "<tr id=\"error_foot\"><td colspan=2></td></tr>\n"; |
|
$tb .= "</table>"; |
|
|
|
return $tb; |
|
} |
|
|
|
private $errors = array(); |
|
private $error = array(); |
|
private $login; |
|
|
|
const LOGIN_ON = "loginON"; |
|
const ERROR_FUNC_NAME = "funcName"; |
|
const ERROR_MESSAGE = "message"; |
|
const ERROR_MSG_SYSTEM = "msgErro"; |
|
const ERROR_MSG_DISPLAY = "msgDisplay"; |
|
const ERROR_FILE = "file"; |
|
|
|
} |
|
|
|
$siteError = new Error("system"); |
|
?>
|
|
|