Ejemplo n.º 1
0
 public function detalhe_cliente($pk_tmk_cliente, $pk_tmk_aluno)
 {
     $msg = null;
     $data = $this->getParametroVisao();
     $data['page'] = 'home';
     $data['tema'] != '' ? $this->load->setTheme($data['tema']) : '';
     $data['msg'] = $msg;
     $data['abaAtiva'] = 24;
     $data['abaPage'] = 'detalhe_cliente';
     $data['alias'] = 'detalhe_cliente';
     $data['total'] = 0;
     if ($_SERVER['REQUEST_METHOD'] == "POST") {
         try {
             // View::validarFormAntInjection($data['alias']);
             if ($this->input->post('enviar_email') == 'on') {
                 $emailDestinatario = $this->input->post('emailDestinatario');
                 $assunto = "Atendimento do Colégio GGE";
                 $headers = 'MIME-Version: 1.0' . "\r\n";
                 $headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";
                 $headers .= "From: " . $data['nomeUsuario'] . " <" . $data['emailUsuario'] . ">" . "\r\n";
                 $mensagem = $this->input->post('interacao');
                 $enviar = mail($emailDestinatario, $assunto, $mensagem, $headers);
             }
             $interacao = $this->input->post('data_evento') != '' ? $this->input->post('interacao') . '<br />Agendado o próximo contato para o dia ' . $this->input->post('data_evento') . ' por ' . $data['nomeUsuario'] : $this->input->post('interacao');
             $sondagem = $this->input->post('sondagem') != '' ? View::converteDataEUA($this->input->post('sondagem')) : '';
             $desistencia = $this->input->post('desistencia') != '' ? $this->input->post('desistencia') : '';
             if ($this->input->post('fk_motivo_desistencia') != '') {
                 $sqlAtendimento = new SqlAtendimento();
                 $sqlAtendimento->editar_cliente_sondagem_desistencia($pk_tmk_cliente, $sondagem, $desistencia, $this->input->post('fk_motivo_desistencia'));
             }
             if ($this->input->post('resultado_teste') != '') {
                 $sqlAtendimento = new SqlAtendimento();
                 $sqlAtendimento->editar_dependente_status($pk_tmk_aluno, $this->input->post('resultado_teste'));
                 $mensagem_resultado_sondagem = $this->input->post('resultado_teste') == 1 ? 'Liberação do resultado do teste de sondagem' : '';
             }
             $interacao_final = isset($mensagem_resultado_sondagem) && $mensagem_resultado_sondagem != '' ? $mensagem_resultado_sondagem : $interacao;
             $sqlAtendimento = new SqlAtendimento();
             $result = $sqlAtendimento->cadastrar_interacao($pk_tmk_cliente, $interacao_final, $this->input->post('nivel_interesse'), $this->input->post('status'), date("Y-m-d H:i:s"), $data['idUsuario']);
             if ($sondagem != '') {
                 // vefifica se a data já consta na tabela sondagem. Se não tiver, inclui e pega a pk do teste de sondagem
                 $sqlAtendimento = new SqlAtendimento();
                 $result = $sqlAtendimento->checa_data_sondagem($sondagem, $this->input->post('fk_serie'), $this->input->post('fk_unidade'));
                 if (count($result) == 0) {
                     if ($this->input->post('fk_serie') == 101 || $this->input->post('fk_serie') == 102 || $this->input->post('fk_serie') == 103 || $this->input->post('fk_serie') == 104 || $this->input->post('fk_serie') == 105 || $this->input->post('fk_serie') == 1 || $this->input->post('fk_serie') == 2 || $this->input->post('fk_serie') == 3 || $this->input->post('fk_serie') == 4 || $this->input->post('fk_serie') == 5) {
                         $sondagem_tipo = 1;
                     } else {
                         $sondagem_tipo = 2;
                     }
                     $sqlAtendimento = new SqlAtendimento();
                     $pk_tmk_sondagem = $sqlAtendimento->cadastrar_sondagem($sondagem, '14:00', $this->input->post('fk_serie'), $this->input->post('fk_unidade'), $sondagem_tipo, 0);
                 } else {
                     $pk_tmk_sondagem = $result[0]['pk_tmk_sondagem'];
                 }
                 $sqlAtendimento = new SqlAtendimento();
                 $sqlAtendimento->reset_datas_sondagem_aluno($pk_tmk_aluno);
                 $sqlAtendimento = new SqlAtendimento();
                 $sqlAtendimento->cadastrar_sondagem_aluno($pk_tmk_sondagem, $pk_tmk_aluno);
             }
             if ($this->input->post('data_evento') != '') {
                 // registra próximo contato
                 $data_proximo_contato = View::converteDataEUA($this->input->post('data_evento')) . ' ' . date("H:i:s");
                 $sqlAtendimento = new SqlAtendimento();
                 $sqlAtendimento->cadastrar_contato($pk_tmk_cliente, $data_proximo_contato, $this->input->post('nivel_interesse'), $this->input->post('status'));
             }
         } catch (Exception $e) {
             $msg = '<p class="alert erro">' . $e->getMessage() . '</p>';
         }
     }
     $sqlAtendimento = new SqlAtendimento();
     $result = $sqlAtendimento->detalhe_cliente($pk_tmk_cliente);
     $data['cliente'] = $result;
     $sqlAtendimento = new SqlAtendimento();
     $result = $sqlAtendimento->get_dependente($pk_tmk_cliente, $pk_tmk_aluno);
     $data['dependentes'] = $result;
     $data['pk_tmk_aluno'] = $result[0]['pk_tmk_aluno'];
     $data['fk_serie'] = $result[0]['fk_serie'];
     $data['fk_unidade'] = $result[0]['fk_unidade'];
     $data['resultado_teste'] = $result[0]['resultado_teste'];
     $sqlAtendimento = new SqlAtendimento();
     $result = $sqlAtendimento->get_data_sondagem_aluno($pk_tmk_aluno);
     if (count($result) > 0) {
         $data['data_sondagem'] = View::converteDataBr($result[0]['data_teste']);
     } else {
         $data['data_sondagem'] = '';
     }
     $sqlAtendimento = new SqlAtendimento();
     $result = $sqlAtendimento->get_interacoes($pk_tmk_cliente);
     $data['total'] = count($result);
     $sqlAtendimento = new SqlAtendimento();
     $data['motivos'] = $sqlAtendimento->get_motivos();
     $tabela = '';
     if ($data['total'] > 0) {
         $tabela .= '<br /><h4>Interações</h4>';
         $tabela .= '<table><tr><th>Atendente</th><th>Interesse</th><th>Status</th><th>Observação</th></tr>';
         $count = 0;
         foreach ($result as $row) {
             $count++;
             $zebrar = Util::zebrarGeral($count, $data['total']);
             $tabela .= '<tr ' . $zebrar . '>';
             $tabela .= '<td>' . $row['atendente_nome'] . '<br />' . View::converteDataBr($row['data_interacao']) . ' às ' . substr($row['data_interacao'], 11, 5) . '</td>';
             $tabela .= '<td class="center">' . View::smilles($row['nivel_interesse']) . '</td>';
             $tabela .= '<td>' . View::status_telemarketing($row['status']) . '</td>';
             $tabela .= '<td>' . $row['interacao'] . '</td>';
             $tabela .= '</tr>';
         }
         $tabela .= '</table>';
         $data['interacoes'] = $tabela;
     }
     if ($this->input->is_ajax_request()) {
         echo json_encode(array('content' => $this->load->view($this->uri->segment(3), $data, true)));
     } else {
         $this->load->view($this->load->getUrlTema(), $data);
     }
 }
Ejemplo n.º 2
0
                </tr>
                <tr>
                    <td class="tright" valign="top"><strong>Dependente:</strong></td>
                    <td>
                        <?php 
foreach ($dependentes as $row) {
    echo $row['nome_aluno'] . ' (' . $row['serie_nome'] . ' - ' . $row['unidade_nome'] . ')<br />';
}
?>
                    </td>
                </tr>
                <tr>
                    <td class="tright"><strong>Status atual:</strong></td>
                    <td>
                        <?php 
echo View::status_telemarketing($cliente[0]['status']);
if ($data_sondagem != '') {
    echo $data_sondagem;
}
?>
                        <?php 
echo $cliente[0]['motivo_desistencia'] != '' ? 'Motivo: ' . $cliente[0]['motivo_desistencia'] : '';
?>
                    </td>
                </tr>
                <tr>
                    <td class="tright"><strong>Observação inicial:</strong></td>
                    <td><?php 
echo $cliente[0]['obs'];
?>
</td>