View
echo form_hidden('id', $table->id);
Then make a send_email function inside controller file.
Controller
public function send_email($id)
{
$leave = $this->one_model->get('table', $id);
$staff = $this->one_model->get('staff', $leave->created_by);
$approver = $this->one_model->get('staff', $staff->leave_approver_id);
$organization = $this->one_model->get('organizations', $leave->org_id);
$apply_date = date_create($leave->created_at);
$apply_date = date_format($apply_date, DATE_FORMAT);
$date_start = date_create($leave->date_start);
$date_start = date_format($date_start, DATE_FORMAT);
$date_end = date_create($leave->date_end);
$date_end = date_format($date_end, DATE_FORMAT);
// construct msg - with invoice link inside
$message = '
Permohonan cuti diterima seperti berikut:
Pemohon Cuti: '.$staff->name.'
Tarikh Permohonan: '.$apply_date.'
Tarikh Mula: '.$date_start.'
Tarikh Akhir: '.$date_end.'
Jumlah Hari: '.$leave->total_day.'
Sebab: '.$leave->reason.'
Untuk memberi maklum balas sila ke localhost/smap/lu/'.$leave->secure_id.'
Terima kasih';
$this->load->library('mailgun');
$this->mailgun->from("$organization->name<postmaster@mg.smap.my>");
$this->mailgun->reply_to($organization->email);
$this->mailgun->to($approver->email);
$this->mailgun->bcc('hello@smap.my');
$this->mailgun->subject("Permohonan Cuti ($staff->name)");
$this->mailgun->message($message);
$this->mailgun->send();
}
Controller process
$id = $post['id'];
$this->send_email($id);
No comments:
Post a Comment