80 lines
No EOL
1.9 KiB
PHP
80 lines
No EOL
1.9 KiB
PHP
<?php
|
|
|
|
/** Importação de classes */
|
|
use vendor\model\CallsDrafts;
|
|
use vendor\controller\calls_drafts\CallsDraftsValidate;
|
|
|
|
/** Instânciamento de classes */
|
|
$CallsDrafts = new CallsDrafts();
|
|
$CallsDraftsValidate = new CallsDraftsValidate();
|
|
|
|
try
|
|
{
|
|
|
|
/** Parâmetros de entrada */
|
|
$CallsDraftsValidate->setCallId(@(int)filter_input(INPUT_POST, 'CALL_ID', FILTER_SANITIZE_SPECIAL_CHARS));
|
|
$CallsDraftsValidate->setCallDraftId(@(int)filter_input(INPUT_POST, 'CALL_DRAFT_ID', FILTER_SANITIZE_SPECIAL_CHARS));
|
|
|
|
/** Verifico a existência de erros */
|
|
if (!empty($CallsDraftsValidate->getErrors()))
|
|
{
|
|
|
|
/** Retorno mensagem de erro */
|
|
throw new InvalidArgumentException($CallsDraftsValidate->getErrors(), 0);
|
|
|
|
}
|
|
else
|
|
{
|
|
|
|
/** Verifico se o usuário foi localizado */
|
|
if ($CallsDrafts->delete($CallsDraftsValidate->getCallDraftId()))
|
|
{
|
|
|
|
/** Result **/
|
|
$result = [
|
|
|
|
'cod' => 200,
|
|
'title' => 'Sucesso',
|
|
'message' => 'Registro removido com sucesso',
|
|
'redirect' => 'FOLDER=VIEW&TABLE=CALLS&ACTION=CALLS_DETAILS&CALL_ID=' . $CallsDraftsValidate->getCallId()
|
|
|
|
];
|
|
|
|
}
|
|
else
|
|
{
|
|
|
|
/** Retorno mensagem de erro */
|
|
throw new InvalidArgumentException('Não foi possivel remover o registro', 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/** Envio **/
|
|
echo json_encode($result);
|
|
|
|
/** Paro o procedimento **/
|
|
exit;
|
|
|
|
}
|
|
catch (Exception $exception)
|
|
{
|
|
|
|
/** Preparo o formulario para retorno **/
|
|
$result = [
|
|
|
|
'cod' => 0,
|
|
'message' => '<div class="alert alert-danger" role="alert">' . $exception->getMessage() . '</div>',
|
|
'title' => 'Atenção',
|
|
'type' => 'exception',
|
|
|
|
];
|
|
|
|
/** Envio **/
|
|
echo json_encode($result);
|
|
|
|
/** Paro o procedimento **/
|
|
exit;
|
|
|
|
} |