|
|
|
@ -5,12 +5,13 @@ require_once __DIR__ . '/../service/ContractService.php';
|
|
|
|
|
require_once __DIR__ . '../../Utils.php'; |
|
|
|
|
|
|
|
|
|
Utils::printToLog('ClickSignController executando.', __LINE__); |
|
|
|
|
|
|
|
|
|
Utils::printToLog(print_r($_REQUEST, true), __LINE__); |
|
|
|
|
Utils::printToLog("\n TESTEEE", __LINE__); |
|
|
|
|
header("Content-Type:application/json"); |
|
|
|
|
if (isset($_GET['idContract']) && $_GET['idContract'] != "") { |
|
|
|
|
$contractId = $_GET['idContract']; |
|
|
|
|
|
|
|
|
|
if (isset($_GET["sendedStatus"]) && $_GET['sendedStatus'] != "" ) { |
|
|
|
|
|
|
|
|
|
if (isset($_GET["sendedStatus"]) && $_GET['sendedStatus'] != "") { |
|
|
|
|
if (ContractService::isSendedContractToClicksign($contractId)) { |
|
|
|
|
Utils::printToLog("O status do contrato id $contractId é: enviado!"); |
|
|
|
|
$response = array( |
|
|
|
@ -22,24 +23,51 @@ if (isset($_GET['idContract']) && $_GET['idContract'] != "") {
|
|
|
|
|
"sended" => "false" |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
echo json_encode($response); |
|
|
|
|
exit; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
ContractService::setProcessingSentToClicksignService($contractId, true); //seta o status processando como verdadeiro |
|
|
|
|
|
|
|
|
|
$sent = ClickSignService::sendToClicksign($contractId); |
|
|
|
|
|
|
|
|
|
$response = array( |
|
|
|
|
"response" => ClickSignService::sendToClicksign($contractId) |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
ContractService::setProcessingSentToClicksignService($contractId, false); //seta o status processando como falso |
|
|
|
|
|
|
|
|
|
$response = mb_convert_encoding($response,"ISO-8859-1","UTF-8"); |
|
|
|
|
|
|
|
|
|
$response = mb_convert_encoding($response, "ISO-8859-1", "UTF-8"); |
|
|
|
|
echo json_encode($response); |
|
|
|
|
exit; |
|
|
|
|
} else if ($_GET['signed'] && $_GET['signed'] != "") { |
|
|
|
|
$json_data = file_get_contents("php://input"); |
|
|
|
|
$data = json_decode($json_data, true); |
|
|
|
|
|
|
|
|
|
Utils::printToLog("testeeeee: " . print_r($data, true)); |
|
|
|
|
|
|
|
|
|
foreach ($data as $key => $value) { |
|
|
|
|
if ($key == "event") { |
|
|
|
|
$event = $value['name']; |
|
|
|
|
|
|
|
|
|
switch ($event) { |
|
|
|
|
case CLOSE_EVENT: |
|
|
|
|
case AUTO_CLOSE_EVENT: |
|
|
|
|
$eventRecord = $event; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ($key == "document") { |
|
|
|
|
$documentKey = $value['key']; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Utils::printToLog('Evento recebido do ClickSign. Key: ' . $documentKey . ". Status: " . $eventRecord); |
|
|
|
|
|
|
|
|
|
if ($eventRecord && $documentKey) { |
|
|
|
|
ClickSignService::setSignedEventClicksignService($documentKey, $eventRecord); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
return 'deu ruim'; |
|
|
|
|
} |
|
|
|
|