How do I retrieve the calling code for my view in the MVC model?

0

Hello, the question is this:

I have a Controller called dinChamado.class.php, with the following methods:

public function comentario()
{          
       $obj_chamado = new daoChamado();
       $this->setVar('sch_codigo',$obj_chamado->recuperaChamado(self::$v_get[0]));
       $this->setVar("acao","adicionar");
       $this->setTPL("form/insuporte/form_comentario.php");
       $this->gerarTemplate();                    
}

public function addComentario(){

       print_r($_REQUEST);
       $_REQUEST['sco_codigo'] = $this->obj_comentario->geraCodigo();
       daoComentario::$ajax = 'T';

       $obj_entComentario = new entComentario();
       $obj_entComentario->setSchCodigo($_POST['sco_sch_codigo']);
       $resposta  = array("resultado"=>"sucesso");
       $resultado = $this->obj_comentario->Inserir();

       if(!$resultado)
       {
             $resposta  = array("resultado"=>"erro","motivo"=>"Ocorreu um erro no processamento");
       }

       echo json_encode($resposta);

}

In daoChamado.class.php there is the following method:

function recuperaChamado($sch_codigo){

     $rs    = $this->especialQuery("SELECT  a.sch_codigo,a.sch_descricao,a.sch_contato,a.sch_ramal,a.sch_tecnico,b.sar_codigo,b.sar_titulo,b.sar_id,b.sar_data_ini,b.sar_data_update,b.sar_data_fim,b.sar_resp_id,b.sar_habilitado,c.spr_codigo,c.spr_problema,c.spr_descricao,c.spr_sla,c.spr_sar_codigo,c.spr_id,c.spr_data_ini,c.spr_data_update,c.spr_data_fim,c.spr_resp_id,c.spr_habilitado,d.sri_codigo,d.sri_prioridade,d.sri_id,d.sri_data_ini,d.sri_data_update,d.sri_data_fim,d.sri_resp_id,d.sri_habilitado,e.sun_codigo,e.sun_unidade,e.sun_id,e.sun_data_ini,e.sun_data_update,e.sun_data_fim,e.sun_resp_id,e.sun_habilitado,f.sts_codigo,f.sts_status,f.sts_id,f.sts_data_ini,f.sts_data_update,f.sts_data_fim,f.sts_resp_id,f.sts_habilitado,a.sch_id,DATE_FORMAT(a.sch_data_ini,'%d/%m/%Y %H:%i:%s') AS sch_data_ini ,DATE_FORMAT(a.sch_data_update,'%d/%m/%Y %H:%i:%s') AS sch_data_update ,DATE_FORMAT(a.sch_data_fim,'%d/%m/%Y %H:%i:%s') AS sch_data_fim ,g.usu_nome,g.usu_login,g.usu_senha,g.usu_cpf,g.usu_flag_adm,g.usu_per_id,g.usu_email,g.usu_telefone,g.usu_celular,g.usu_id,g.usu_data_ini,g.usu_data_update,g.usu_data_fim,g.usu_resp_id,g.usu_habilitado,a.sch_habilitado FROM insuporte_chamado as a  LEFT JOIN insuporte_area AS b ON  a.sch_sar_codigo = b.sar_codigo LEFT JOIN insuporte_problema AS c ON  a.sch_spr_codigo = c.spr_codigo LEFT JOIN insuporte_prioridade AS d ON  a.sch_sri_codigo = d.sri_codigo LEFT JOIN insuporte_unidade AS e ON  a.sch_sun_codigo = e.sun_codigo LEFT JOIN insuporte_status AS f ON  a.sch_sts_codigo = f.sts_codigo LEFT JOIN sistema_usuario AS g ON  a.sch_resp_id = g.usu_id WHERE 1= 1  AND  sch_st_id = 1 AND sch_codigo = '".$sch_codigo."'  ");
                    return $rs; 
}

In the Comment method of the controller I am generating the TPL (template) and the variable to be sent to the TPL form_comentario.php.

In the addComentario method this is inserting the fields but not the sco_sch_codigo field which is the foreign key (FK that binds the two entities called and Comment. I tried several ways giving $ _REQUEST with $ _POST and with variable but I could not, if you can help thank you.

    
asked by anonymous 30.09.2016 / 18:08

0 answers