⚠ In case you've missed it we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This forum is read-only and soon will be archived. ⚠


I have a problem with a callback

bug update true insert model

  • Please log in to reply
No replies to this topic

#1 Leandro Oliveira

Leandro Oliveira

    Newbie

  • Members
  • Pip
  • 1 posts

Posted 02 September 2019 - 02:43 PM

I have this callback 

 public function status() 
    {
        $status = $this->input->post('status');
        if ($status === "Confirmado") 
        {
            $status = $this->input->post('status');
            $dTimeIni = new DateTime($this->input->post('data_hora_ini'));
            $dTimeFim = new DateTime($this->input->post('data_hora_fim'));
            $id_consultorio = $this->input->post('id_consultorio');
            $id_profissional = $this->input->post('id_profissional');
            $this->load->model('agenda/consultas_model');
            $result = $this->consultas_model->confirmar($id_consultorio, $id_profissional, $status, $dTimeIni, $dTimeFim);
            if ($result == false) 
            {
                return true;
            }
            else if ($result == true) 
            {
                $this->form_validation->set_message('status', 'Consultorio ou Medico não disponiveis para esse horario');
                return false;
            }
        }
         if ($status === "Cancelado") 
        {
            $id_agenda = $this->input->post('id_agenda');
            $this->load->model('agenda/consultas_model');
            $result = $this->consultas_model->cancelar_consultas($id_agenda);
            
            if ($result == true) 
            {
                return true;
                
            }
            else if ($result == false) 
            {
                $this->form_validation->set_message('status', 'Não foi possivel cancelar essa consulta');
                return false;
            }
        }
    }

when the condition Cancelado is activated calls this function in the model

function cancelar_consultas($id_agenda)
	{
	    $this->db->set('status', 'Cancelado');
	    $this->db->where('id_agenda =',$id_agenda);
	    $this->db->or_where('id_rel =',$id_agenda);
	    $this->db->update('agd_consultas');
        $num=$this->db->affected_rows();
        
        if ($num > 0 )
		{                     
		    return true;
		}
		else
		{

		    return false;
		}

	}
when update a grocery returns me a true and then a false
I don't know why this is happening I need help






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users