I have a Codeigniter form like the following:
When I click on the green check sign for "Approve" or the red cross sign for "Reject" , an email is supposed to be sent to certain addresses. But I've checked that the mail was never sent.
For better understanding, here are some of my codes:
View:
<td class="center">
<?php
$edit_text = (ACTION_BUTTON_TEXT_SHOW) ? 'Approve' : ' ';
echo anchor('staff_requisitions/update_approve/' . $row['id'],"<img src='".base_url()."/media/images/accept.png'>", $edit_text, array('class' => 'edit_button', 'title' => 'Approve'));
?>
</td>
<td class="center">
<?php
$edit_text = (ACTION_BUTTON_TEXT_SHOW) ? 'Reject' : ' ';
echo anchor('staff_requisitions/update_reject/' . $row['id'],"<img src='".base_url()."/media/images/reject.png'>", $edit_text, array('class' => 'edit_button', 'title' => 'Reject'));
?>
</td>
Controller:
function __construct()
{
parent::__construct();
$this->load->database();
$this->load->model('Staff_requisition');
$this->load->helper('url');
$this->load->helper('html');
$this->load->helper('form');
$this->load->library('email');
$this->output->enable_profiler(false);
}
function update_approve(){
$id = $this->uri->segment(3);
$this->Staff_requisition->update_approve($id);
//$data['list_of_emails'] = $this->Staff_requisition->get_list_of_emails($id);
$this->email->from('joshamee_gibbs@example.com', 'Joshamee');
$this->email->to('capn_jack_sparrow@example.com');
$this->email->cc('william.turner1724@example.com');
$this->email->subject('Email Test');
$this->email->message('Testing the email class. Your requisition approved.');
$this->email->send();
echo $this->email->print_debugger();
$this->session->set_flashdata('message', 'The requisition request has been approved');
redirect('staff_requisitions/index');
}
function update_reject(){
$id = $this->uri->segment(3);
$this->Staff_requisition->update_reject($id);
//$data['list_of_emails'] = $this->Staff_requisition->get_list_of_emails($id);
$this->email->from('joshamee_gibbs@example.com', 'Joshamee');
$this->email->to('capn_jack_sparrow@example.com');
$this->email->cc('william.turner1724@example.com');
$this->email->subject('Email Test');
$this->email->message('Testing the email class. Your requisition rejected.');
$this->email->send();
echo $this->email->print_debugger();
$this->session->set_flashdata('message', 'Sorry, the requisition request has been rejected');
redirect('staff_requisitions/index');
}
Model:
function __construct()
{
parent::__construct();
}
function update_approve($rid){
$this->db->query("UPDATE `staff_requisitions` SET `is_approve` = 1 WHERE `id` = $rid ");
}
function update_reject($rid){
$this->db->query("UPDATE `staff_requisitions` SET `is_approve` = 0 WHERE `id` = $rid ");
}
function get_list_of_emails($id){
$q = $this->db->query("SELECT * FROM `requisition_emails` WHERE `req_id` = $id")->result_array();
return $q;
}
What am I missing/doing wrong?
N.b. I'm running this application in localhost.