$tot_tudo = $tot_tudo + $total_rows[$i];
    $i++;
}
$HTML .= "<td style=\"border:solid 1px #999;text-align:center;font-weight:bold;font-size:13px\">" . $tot_tudo . "</td>\n";
$HTML .= "\t</tr>\n";
#echo $HTML; exit;
$HTML .= '</table>';
$HTML .= '<table cellpadding="1" cellspacing="4" style="font-family:Arial;font-size:11px; border:none;">
	<tr>
		<td style="border:solid 1px #999;font-weight:bold;background-color:#CCC;width:40px;">&nbsp;FICHA</td>
		<td style="border:solid 1px #999;font-weight:bold;background-color:#CCC;width:180px;">&nbsp;CONSULTOR</td>
		<td style="border:solid 1px #999;font-weight:bold;background-color:#CCC;width:140px;">&nbsp;HORA / DATA</td>
		<td style="border:solid 1px #999;font-weight:bold;background-color:#CCC;width:140px;">&nbsp;STATUS</td>
		<td style="border:solid 1px #999;font-weight:bold;background-color:#CCC;">&nbsp;CONVERSAS</td>
	</tr>';
$observacao = $expansao->listarfichaiddia();
$conversa = $expansao->listarfichadia();
$ids = array();
foreach ($observacao as $b1 => $res) {
    $color = ' style="background-color:#F3F3F3"';
    $border = ';border-top:solid 2px #999';
    $HTML .= '<tr' . $color . '>		
			<td style="border:solid 1px #999;text-align:center' . $border . ';font-weight:bold">&nbsp;' . $res->id_ficha . '</td>
			<td style="border:solid 1px #999' . $border . ';font-weight:bold">&nbsp;' . $res->consultor . '</td>
			<td style="border:solid 1px #999' . $border . ';text-align:center;font-weight:bold" colspan="3">&nbsp;' . $res->status . ' [ <span style="color:#CC0000">' . utf8_decode('Região Interesse:') . ' ' . strtoupper(strtolower($res->cidade_interesse . ' / ' . $res->estado_interesse)) . '</span> ]' . '</td>
		</tr>';
    $ids[] = $res->id_ficha;
    $ficha = 0;
    $historico = $expansao->listarHistorico($res->id_ficha);
    if (count($historico) > 0) {
        for ($j = 0; $j < count($historico); $j++) {