public function ativaContingencia($siglaUF = '', $motivo = '', $tipo = '')
{
if ($siglaUF == '' || $motivo == '') {
return false;
}
if ($this->enableSVCAN || $this->enableSVCRS || $this->enableEPEC) {
return true;
}
$this->motivoContingencia = $motivo;
$this->tsContingencia = time();
// mktime() necessita de paramentos...
$ctgList = array('AC' => 'SVCAN', 'AL' => 'SVCAN', 'AM' => 'SVCAN', 'AP' => 'SVCRS', 'BA' => 'SVCRS', 'CE' => 'SVCRS', 'DF' => 'SVCAN', 'ES' => 'SVCRS', 'GO' => 'SVCRS', 'MA' => 'SVCRS', 'MG' => 'SVCAN', 'MS' => 'SVCRS', 'MT' => 'SVCRS', 'PA' => 'SVCRS', 'PB' => 'SVCAN', 'PE' => 'SVCRS', 'PI' => 'SVCRS', 'PR' => 'SVCRS', 'RJ' => 'SVCAN', 'RN' => 'SVCRS', 'RO' => 'SVCAN', 'RR' => 'SVCAN', 'RS' => 'SVCAN', 'SC' => 'SVCAN', 'SE' => 'SVCAN', 'SP' => 'SVCAN', 'TO' => 'SVCAN');
$ctg = $ctgList[$siglaUF];
$this->enableSVCAN = false;
$this->enableSVCRS = false;
$this->enableEPEC = false;
if ($tipo == 'EPEC') {
$this->enableEPEC = true;
} else {
if ($ctg == 'SVCAN') {
$this->enableSVCAN = true;
} elseif ($ctg == 'SVCRS') {
$this->enableSVCRS = true;
}
}
$aCont = array('motivo' => $this->motivoContingencia, 'ts' => $this->tsContingencia, 'SVCAN' => $this->enableSVCAN, 'SVCRS' => $this->enableSVCRS, 'EPEC' => $this->enableEPEC);
$strJson = json_encode($aCont);
$filename = NFEPHP_ROOT . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . $this->aConfig['cnpj'] . '_contingencia.json';
file_put_contents($filename, $strJson);
return true;
}