Good evening I have the method below that adds filled values of a modal
public function ajax_add()
{
$this->_validate();
$data = array(
'owner' => $this->input->post('owner'),
'dpo' => $this->input->post('dpo'),
'grupo' => $this->input->post('grupo'),
'sub_grupo' => $this->input->post('sub_grupo'),
'semana' => $this->input->post('semana'),
'cod_id' => $this->input->post('cod_id'),
'atividade' => $this->input->post('atividade'),
'obj_esperado' => $this->input->post('obj_esperado'),
'alcancado' => $this->input->post('alcancado'),
'conc_esti' => $this->input->post('conc_esti'),
'anl_envolvidos' => $this->input->post('anl_envolvidos'),
);
$insert = $this->projeto->save($data);
echo json_encode(array("status" => TRUE));
However, I need to pass two more fixed values in this addition which will be:
'operacao' => $this->input->post("INS"),
'data_reg' => $this->input->post(NOW()),
This will serve to include what operation is being done and the date. These values will not come from FORM MODAL, they will have to be fixed.
My addition or update ajax, it looks like this:
function save()
{
$('#btnSave').text('salvando...'); //change button text
$('#btnSave').attr('disabled',true); //set button disable
var url;
if(save_method == 'add') {
url = "<?php echo site_url('projeto/ajax_add')?>";
} else {
url = "<?php echo site_url('projeto/ajax_update')?>";
}
// ajax adding data to database
$.ajax({
url : url,
type: "POST",
data: $('#form').serialize(),
dataType: "JSON",
success: function(data)
{
if(data.status) //if success close modal and reload ajax table
{
$('#modal_form').modal('hide');
reload_table();
}
else
{
for (var i = 0; i < data.inputerror.length; i++)
{
$('[name="'+data.inputerror[i]+'"]').parent().parent().addClass('has-
error'); //select parent twice to select div form-group class and add
has-error class
$('[name="'+data.inputerror[i]+'"]').next().text(data.error_string[i]);
//select span help-block class set text error string
}
}
$('#btnSave').text('save'); //change button text
$('#btnSave').attr('disabled',false); //set button enable
},
error: function (jqXHR, textStatus, errorThrown)
{
alert('Erro adicionando ou atualizando registro');
$('#btnSave').text('save'); //change button text
$('#btnSave').attr('disabled',false); //set button enable
}
});
}
How could I do this? I did some testing but no success.
Thank you very much.