<?php

if(!defined('BASEPATH')) exit('Hacking Attempt : Get Out of the system ..!');

class Broadcast_model extends CI_Model
{
	public function __construct(){
		parent::__construct();
	}
	
	
	public function get_merchant_templates($merchantId){
		$sql='SELECT templates.templatename,templates.templateId FROM templates LEFT JOIN template_merchant ON template_merchant.`templateId`=templates.`templateId` WHERE template_merchant.`merchantId`="'.$merchantId.'" OR template_merchant.`merchantId`=0';
		 $query = $this->db->query($sql);
    	 return $query->result();
	}
	
	public function get_merchant_messages($merchantId){
		$sql='SELECT messages.*,templates.`name` FROM messages LEFT JOIN templates ON templates.`templateId`=messages.`templateId` WHERE messages.`merchantId`="'.$merchantId.'"';
		 $query = $this->db->query($sql);
    	 return $query->result();
	}
	
	public function insert_merchant_campaign($entry){
		$this->db->insert('messages', $entry);
	}
	
	public function insert_merchant_campaign_bulk($data){
		$this->db->insert_batch('messages', $data);
		//echo $this->db->last_query();
	}
	
}

?>