$v){ execSQL("UPDATE codigos_list SET cupom_id = '0' WHERE cupom_id = '{$v['id']}' LIMIT 1"); } execSQL("DELETE FROM cupons WHERE cadastro_id = '$id'"); die(EXCLUIDO); }else{ die(ERROR); } }elseif($funcao == "status"){ if(empty($id) || $status == "") die(VNPFI); $sql = "UPDATE cadastros SET ativo = '$status', updated = '$agora' WHERE id = '$id' LIMIT 1"; if(execSQL($sql)){ die(PROCESSADO); }else{ die(ERROR); } }elseif($funcao === "exportarExcel"){ $sql = getDadosList($_SESSION['query']); foreach($sql as $i => $v){ $cadastro = dataHora($v['created']); $linhas[] = array( $cadastro, $v['nome'], $v['email'], $v['rCupons'], ); } $header = array( "cadastro" => "string", "nome" => "string", "email" => "string", "cupons" => "string", ); $post = json_encode(utf8_encode_array(array( "header" => $header, "linhas" => $linhas, ))); // $curl = fetchCURL("https://www.premiumart.com.br/sites/geraxml/xml.php", array("dados" => $post), "POST"); $arquivo = "lista-cadastros.xlsx"; file_put_contents($arquivo, $curl[0]); header('Content-type: application/save');//octet/stream header('Content-disposition: attachment; filename="'.$arquivo.'";'); header('Content-Length: '.filesize($arquivo)); readfile($arquivo); unlink($arquivo); // die(); }else{ die(VNPFI); }