0
I am developing a scheduling system (automotive sector).
The idea is for the user to choose an installer(ComboBox
), Schedule(ComboBox
) these times are already predefined and the date(Input
/Date
).
I am trying to create a condition where, if the installer already has scheduling at that date and time, there is no possibility to reschedule (duplicate), and display a warning message.
CONTROLLER:
$dados = array(
'tecAg' => $this->input->post('tecAg'),
'horaAgIns' => $this->input->post('horaAgIns'),
'data' => $this->input->post('data')
);
$this->load->model('agendamentos_model');
if(!$this->agendamentos_model->verifica($dados['horaAgIns' && 'tecAg' && 'data'])) {
echo 'Horário já utilizado!';
} else {
$data = array(
'tecAg' => set_value('tecAg'),
'horaAg' => set_value('horaAg'),
'data' => set_value('data'),
MODEL:
public function verifica($tecAg, $horaAgIns, $data){
$this->db->where('tecAg', $tecAg);
$this->db->where('horaAgIns', $horaAgIns);
$this->db->where('data', $data);
return $this->db->get('agendamentos')->row_array();
}
First, thank you very much for the reply Vitorzf.
– CLEBER_89
My idea is that these three fields (tecAg, timeAgIns, date) receive this data via form input and make this query in the database before saving the records, there are more fields in the form but the idea was only to let save if these times are available. There is already an Add() function. So I tried to use an If inside this same function. @Vitorzf
– CLEBER_89
In this case you can do it this way, https://repl.it/repls/GhostwhiteColdWorkplace
– VitorZF
I got it here, using the same IF, it was just the logic that was wrong. Thank you so much for the strength @Vitorzf
– CLEBER_89