Code:
else
{
$searchcode = $this->input->post('searchcode', true);
//Query 1 - Search database for user records that match the searchcode
$q1 = $this->db->from('users')
->where('scancode', $searchcode)
->get();
if ($q1->num_rows() > 0)
{
$this->data['user'] = $q1->row();
//Query 2 - Get sum of account from transaction DB
$q2 = $this->db->select('SUM(amount) as sum_amount', FALSE)
->from('transactions')
->where('email', $this->data['user']->email)
->group_by('email')
->get();
if ($q2->num_rows() > 0)
{
$this->data['sum'] = $q2->row()->sum_amount;
}
//Query 3 - Get the last 3 transaction records for user
$q3 = $this->db->from('transactions')
->where('email', $this->data['user']->email)
->order_by('tid','DESC')
->limit(3)
->get();
if ($q3->num_rows() > 0)
{
$this->data['amount'] = $q3->result();
}
// pass new transaction form fields to the view page
$this->data['email'] = array('name' => 'email',
'id' => 'email',
'type' => 'hidden',
'value' => $this->data['user']->email,
);
$this->data['searchcode'] = array('name' => 'searchcode',
'id' => 'searchcode',
'type' => 'hidden',
'value' => $this->input->post('searchcode', true),
);
$this->data['qty1'] = array('name' => 'qty1',
'id' => 'qty1',
'type' => 'text',
'value' => $this->form_validation->set_value('qty1'),
);
$this->data['qty2'] = array('name' => 'qty2',
'id' => 'qty2',
'type' => 'text',
'value' => $this->form_validation->set_value('qty2'),
);
$this->data['qty3'] = array('name' => 'qty3',
'id' => 'qty3',
'type' => 'text',
'value' => $this->form_validation->set_value('qty3'),
);
$this->data['qty4'] = array('name' => 'qty4',
'id' => 'qty4',
'type' => 'text',
'value' => $this->form_validation->set_value('qty4'),
);
$this->data['qty5'] = array('name' => 'qty5',
'id' => 'qty5',
'type' => 'text',
'value' => $this->form_validation->set_value('qty5'),
);
$this->data['qty6'] = array('name' => 'qty6',
'id' => 'qty6',
'type' => 'text',
'value' => $this->form_validation->set_value('qty6'),
);
$this->data['options'] = array(
'B' => 'B/W',
'C' => 'Color',
'F' => 'Staples',
'U' => 'USB',
'S' => 'Scanning',
'E' => 'Scan Email',
'D' => 'Deposit',
'R' => 'Refund',
);
$this->data['pr1'] = array('name' => 'pr1',
'id' => 'pr1',
'type' => 'text',
'value' => $this->form_validation->set_value('pr1'),
);
$this->data['pr2'] = array('name' => 'pr2',
'id' => 'pr2',
'type' => 'text',
'value' => $this->form_validation->set_value('pr2'),
);
$this->data['pr3'] = array('name' => 'pr3',
'id' => 'pr3',
'type' => 'text',
'value' => $this->form_validation->set_value('pr3'),
);
$this->data['pr4'] = array('name' => 'pr4',
'id' => 'pr4',
'type' => 'text',
'value' => $this->form_validation->set_value('pr4'),
);
$this->data['pr5'] = array('name' => 'pr5',
'id' => 'qty5',
'type' => 'text',
'value' => $this->form_validation->set_value('pr5'),
);
$this->data['pr6'] = array('name' => 'pr6',
'id' => 'pr6',
'type' => 'text',
'value' => $this->form_validation->set_value('pr6'),
);
$this->data['admin'] = array('name' => 'admin',
'id' => 'admin',
'type' => 'text',
'value' => $this->form_validation->set_value('admin'),
);
$this->data['message'] = (validation_errors() ? validation_errors() : ($this->ion_auth->errors() ? $this->ion_auth->errors() : $this->session->flashdata('message')));
$this->template
->title( 'Last Minute Printing', 'Print Card')
->set_layout('default')
->build('auth/scan_view', $this->data);
}
}
}
}