shop.balmet.com

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

online.php (759B)


      1 <?php
      2 class ModelExtensionDashboardOnline extends Model {
      3 	public function getTotalOnline($data = array()) {
      4 		$sql = "SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "customer_online` co LEFT JOIN " . DB_PREFIX . "customer c ON (co.customer_id = c.customer_id)";
      5 
      6 		$implode = array();
      7 
      8 		if (!empty($data['filter_ip'])) {
      9 			$implode[] = "co.ip LIKE '" . $this->db->escape($data['filter_ip']) . "'";
     10 		}
     11 
     12 		if (!empty($data['filter_customer'])) {
     13 			$implode[] = "co.customer_id > 0 AND CONCAT(c.firstname, ' ', c.lastname) LIKE '" . $this->db->escape($data['filter_customer']) . "'";
     14 		}
     15 
     16 		if ($implode) {
     17 			$sql .= " WHERE " . implode(" AND ", $implode);
     18 		}
     19 
     20 		$query = $this->db->query($sql);
     21 
     22 		return $query->row['total'];
     23 	}
     24 }