if (substr($opt, 0, 3) == 'doc') {
         $arrTmp = getOpcao($arrOpcoes, 'id', $opt);
         fwrite($fp, $arrTmp[0]['label'] . ': ' . $doc[$arrTmp[0]['campo']] . "\n");
     } elseif (substr($opt, 0, 3) == 'prz') {
         if ($opt == 'prz-ppa') {
             $buscarPPA = true;
         } elseif ($opt == 'prz-exec_orc') {
             $buscarExecOrc = true;
         } else {
             $buscarPrazos = true;
         }
     }
 }
 //PRAZOS (DEMANDAS)
 if ($buscarPrazos || $buscarPPA || $buscarExecOrc) {
     $arrDem = VinculacaoDemanda::listarVinculados($idDocumento, 'p', 3);
     if ($arrDem !== false) {
         for ($i = 0; $i < count($arrDem); $i++) {
             $prazo = DaoPrazoDemanda::getPrimeiroPrazo($arrDem[$i]['DIGITAL']);
             if (is_null($prazo['dt_resposta'])) {
                 $prazo['legislacao_situacao'] = '';
             } else {
                 $prazo['legislacao_situacao'] = $prazo['legislacao_situacao_descricao'];
             }
             fwrite($fp, "\n----- DEMANDA " . ($i + 1) . " -----\n");
             foreach ($arrOpcSel as $opt) {
                 if ($opt != 'prz-ppa' && $opt != 'prz-exec_orc') {
                     if (substr($opt, 0, 3) == 'prz') {
                         /*
                         										 if (!isset($arrSaidaPrz[$prazo['sq_prazo']])) {
                         										$arrSaidaPrz[$prazo['sq_prazo']] = array();
include_once __BASE_PATH__ . '/extensoes/pr_snas/1.0/classes/VinculacaoDemanda.php';
try {
    $out = array();
    switch ($_REQUEST['acao']) {
        case 'carregar-passiveis':
            $digitais = VinculacaoDemanda::getDocumentosPassiveisVinculacao($_REQUEST['digital']);
            foreach ($digitais as $key => $value) {
                $out[] = array($value['DIGITAL'] => $value['DIGITAL']);
            }
            break;
        case 'carregar-vinculados':
            $digitais = VinculacaoDemanda::getDocumentosVinculados($_REQUEST['pai'], $_REQUEST['vinculacao']);
            foreach ($digitais as $key => $value) {
                $out[] = array($value['FILHO'] => $value['FILHO']);
            }
            break;
        case 'vincular':
            $vinculacao = new VinculacaoDemanda();
            $out = $vinculacao->vincularDocumento($_REQUEST['pai'], $_REQUEST['filho'], $_REQUEST['vinculacao'])->toArray();
            break;
        case 'desvincular':
            $vinculacao = new VinculacaoDemanda();
            $out = $vinculacao->desvincularDocumento($_REQUEST['pai'], $_REQUEST['filho'], $_REQUEST['vinculacao'])->toArray();
            break;
        default:
            break;
    }
    print json_encode($out);
} catch (PDOException $e) {
    echo $e->getMessage();
}