[eluser]The Revel[/eluser]
What i am trying to do is redirect to the same page after I am done, however the page is called via a variable pulled from a search.
Its a barcode system, you scan the barcode in a search and it comes up with the users page, along with their transactions, you make a new transaction and it should come back to the users page, however, upon redirect I get a blank page because I did not pass the barcode back. Is there a way to pass it via a reditect or some way that i do not have to duplicate my code (which I had done previously, but its just shorter that after you do the DB sequences it redirects instead of re-rendering the page).
Here is the full function, you can see why I don't wanna increase it any more:
Had to break it in two cuz of forum limitations:
Part 1:
Code:
function search_scancode()
{
if (!$this->ion_auth->logged_in())
{
//redirect them to the login page
redirect('auth/login', 'refresh');
}
elseif (!$this->ion_auth->is_admin())
{
//redirect them to the home page because they must be an administrator to view this
redirect($this->config->item('base_url'), 'refresh');
}
else
{
//validate form input
$this->form_validation->set_rules('qty1', 'First Quantity', 'required|xss_clean');
$this->form_validation->set_rules('pr1', 'First Price', 'required|xss_clean');
$this->form_validation->set_rules('admin', 'Admin ID', 'required|xss_clean');
$this->form_validation->set_rules('qty2', 'Second Quantity', 'xss_clean');
$this->form_validation->set_rules('qty3', 'Third Quantity', 'xss_clean');
$this->form_validation->set_rules('qty4', 'Fourth Quantity', 'xss_clean');
$this->form_validation->set_rules('qty5', 'Fifth Quantity', 'xss_clean');
$this->form_validation->set_rules('qty6', 'Sixth Quantity', 'xss_clean');
$this->form_validation->set_rules('pr2', 'Second Price', 'xss_clean');
$this->form_validation->set_rules('pr3', 'Third Price', 'xss_clean');
$this->form_validation->set_rules('pr4', 'Forth Price', 'xss_clean');
$this->form_validation->set_rules('pr5', 'Fifth Price', 'xss_clean');
$this->form_validation->set_rules('pr6', '6th price', 'xss_clean');
if ($this->form_validation->run() == true)
{
$datestring = "%Y-%m-%d";
$time = time();
$date = mdate($datestring, $time);
$new_tr1 = array('date' => $date,
'qty' => $this->input->post('qty1'),
'total' => $this->input->post('qty1') * $this->input->post('pr1'),
'code' => $this->input->post('code1'),
'admin' => $this->input->post('admin'),
);
$this->db->insert('records', $new_tr1);
if ($this->input->post('qty2'))
{
$new_tr2 = array('date' => $date,
'qty' => $this->input->post('qty2'),
'total' => $this->input->post('qty2') * $this->input->post('pr2'),
'code' => $this->input->post('code2'),
'admin' => $this->input->post('admin'),
);
$this->db->insert('records', $new_tr2);
}
if ($this->input->post('qty3'))
{
$new_tr3 = array('date' => $date,
'qty' => $this->input->post('qty3'),
'total' => $this->input->post('qty3') * $this->input->post('pr3'),
'code' => $this->input->post('code3'),
'admin' => $this->input->post('admin'),
);
$this->db->insert('records', $new_tr3);
}
if ($this->input->post('qty4'))
{
$new_tr4 = array('date' => $date,
'qty' => $this->input->post('qty4'),
'total' => $this->input->post('qty4') * $this->input->post('pr4'),
'code' => $this->input->post('code4'),
'admin' => $this->input->post('admin'),
);
$this->db->insert('records', $new_tr4);
}
if ($this->input->post('qty5'))
{
$new_tr5 = array('date' => $date,
'qty' => $this->input->post('qty5'),
'total' => $this->input->post('qty5') * $this->input->post('pr5'),
'code' => $this->input->post('code5'),
'admin' => $this->input->post('admin'),
);
$this->db->insert('records', $new_tr5);
}
if ($this->input->post('qty6'))
{
$new_tr6 = array('date' => $date,
'qty' => $this->input->post('qty6'),
'total' => $this->input->post('qty6') * $this->input->post('pr6'),
'code' => $this->input->post('code6'),
'admin' => $this->input->post('admin'),
);
$this->db->insert('records', $new_tr6);
}
$total = (($this->input->post('qty1') * $this->input->post('pr1')) + ($this->input->post('qty2') * $this->input->post('pr2')) + ($this->input->post('qty3') * $this->input->post('pr3')) + ($this->input->post('qty4') * $this->input->post('pr4') + ($this->input->post('qty5') * $this->input->post('pr5')) + ($this->input->post('qty6') * $this->input->post('pr6')))) * -1 ;
$full_tr = array('email' => $this->input->post('email'),
'amount' => $total,
'date' => $date,
'admin' => $this->input->post('admin'),
);
$this->db->insert('transactions', $full_tr);
$this->session->set_flashdata('message', "Transaction(s) Added");
//redirect them to the login page
redirect('auth/search_scancode', 'refresh');
}