<?php
class ModelCatalogSystemNotification extends Model
{

    public function getSystemNotifications($data = array())
    {
        $sql = "SELECT * FROM " . DB_PREFIX . "notification WHERE date_added IS NOT NULL";


        if (isset($data['notification_status'])) {
            $sql .= " AND notification_status=" . $this->db->escape($data['notification_status']);
        }

        $sql .= " ORDER BY priority, date_added";

        $query = $this->db->query($sql);

        return $query->rows;
    }


    public function getSystemNotification($store_rating_id)
    {
        $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "notification WHERE notification_status = " . (int)$store_rating_id);
        return $query->row;
    }

    public function getTotalNotify(){
        $sql = "SELECT count(*) total FROM " . DB_PREFIX . "notification WHERE ";
        $sql .= " notification_status = 1";


        $query = $this->db->query($sql);

        return $query->row['total'];
    }


    public function updateNotificationRead($data){

        $sql = "   UPDATE " . DB_PREFIX . "notification
				      SET notification_status = 0,
					      date_confirmation = CURDATE()
					WHERE notification_id = {$data['selected']} ";

        $result = $this->db->query($sql);

        return $result;

    }
}
?>