first commit
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
<?php if (!defined('BASEPATH')) {
|
||||
exit('No direct script access allowed');
|
||||
}
|
||||
|
||||
class Notification_model extends CI_Model {
|
||||
|
||||
private $read_replica;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->read_replica = $this->load->database('savvy_replica', TRUE);
|
||||
}
|
||||
|
||||
public function updateDescription($data) {
|
||||
$this->db->set('action_detail', $data['description']);
|
||||
$this->db->where('id', (int)$data['id']);
|
||||
$this->db->update('email_trigger');
|
||||
|
||||
return $this->db->affected_rows();
|
||||
}
|
||||
|
||||
|
||||
public function get_all_record_notifications(
|
||||
$filters,
|
||||
$limit = null,
|
||||
$offset = null
|
||||
) {
|
||||
$this->read_replica->select(
|
||||
'mn.added AS added,
|
||||
mn.expire AS expire,
|
||||
(CASE WHEN m.alert_notification=1 THEN \'Yes\' ELSE \'No\' END) AS sendAlert,
|
||||
(CASE WHEN m.alert_email=1 THEN \'Yes\' ELSE \'No\' END) AS emailAlert,
|
||||
mn.trigger_key AS trigger_key,
|
||||
mn.notice_type AS notice_type,
|
||||
mn.msg AS msg,
|
||||
(
|
||||
CASE
|
||||
WHEN mn.status=1 THEN \'Pending\'
|
||||
WHEN mn.status=5 THEN \'Completed\'
|
||||
WHEN mn.status=2 THEN \'Expired\'
|
||||
WHEN mn.status=3 THEN \'Cancelled\'
|
||||
ELSE \'No\' END
|
||||
) AS msg_status,
|
||||
mn.mmode AS mmode,
|
||||
mn.id AS id_members_notification,
|
||||
m.id AS id_members'
|
||||
);
|
||||
|
||||
$this->read_replica->from('members_notification mn');
|
||||
$this->read_replica->join('members m', 'm.id = mn.member_id', 'left');
|
||||
|
||||
foreach ($filters as $key => $value) {
|
||||
if ($key === 'member_id') {
|
||||
$this->read_replica->where('mn.member_id', $value);
|
||||
} else if ($key === 'start_date') {
|
||||
$this->read_replica->where('DATE(mn.added) >=', $value);
|
||||
} else if ($key === 'end_date') {
|
||||
$this->read_replica->where('DATE(mn.added) <=', $value);
|
||||
} else if ($key === 'msg_status') {
|
||||
$this->read_replica->where('mn.status =', $value);
|
||||
} else {
|
||||
$this->read_replica->like('lower(' . $key . ')', strtolower($value));
|
||||
}
|
||||
}
|
||||
|
||||
if ($limit) {
|
||||
$this->read_replica->limit($limit, $offset);
|
||||
$this->read_replica->order_by('mn.added DESC');
|
||||
}
|
||||
return $this->read_replica->get()->result_array();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user