<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Party_comments extends CI_Controller {
	public function __construct(){
		parent::__construct();
		$this->load->model('common_model');
		$this->load->model('users_model');
		if(get_cookie('admin_id'))
		{
			$this->session->set_userdata('admin_id',get_cookie('admin_id'));
		}
		if(!$this->session->userdata('admin_id'))
		{
			redirect('admin/login');
		}
	}
	public function index(){
		$content_data = array();
		if($this->input->post()){
			$ids = $this->input->post('ids');
			if($ids){
				foreach ($ids as $key => $value) {
					$this->common_model->UpdateData('review_comments',array('approved'=>1),array('id'=>$value));
				}
			}
		}
		$data['loginDetails'] = $this->common_model->getAllRow('feu_userdetails',array('id'=>$this->session->userdata('admin_id')),array('usr_users','feu_userdetails.user_id = usr_users.id')) ;
		
		$content_data['party_comments'] = $this->common_model->getAllMultipleJoin('review_comments','',array(array('feu_userdetails','feu_userdetails.user_id = review_comments.user_id'),array('evt_events','evt_events.id = review_comments.event_id')),'review_comments.approved ASC','*, review_comments.id');
		//print_r($content_data['party_comments']);die;
		//echo $this->db->last_query(); die;
		$data['content'] = $this->load->view('admin/party_comments/list', $content_data, TRUE);
		$this->load->view('admin/layout', $data);
	}
	public function status($enc_userID='')
	{
		if($enc_userID!='')
		{
			$Id=base64_decode($enc_userID);
			$this->common_model->UpdateData('review_comments',array('approved'=>1),array('id'=>$Id));
			redirect(base_url().'admin/party_comments');
		}
		else
		{
			$this->utility->setMsg('Invalid id','ERROR');	
			redirect(base_url().'admin/party_comments');
		}
	}
	
}