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

class Unpaid_users extends CI_Controller {
	public function __construct(){
		parent::__construct();
		$this->load->model('common_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();
		$res = $this->db->query("SELECT usr_users.created, username, email, COUNT('shop_carts.id') count, shop_carts.user_id FROM shop_orders LEFT JOIN shop_carts ON shop_carts.id = shop_orders.cart_id LEFT JOIN usr_users ON usr_users.id = shop_carts.user_id LEFT JOIN feu_userdetails ON feu_userdetails.user_id = usr_users.id WHERE payed = 0 AND is_booking = 1 AND email is not null GROUP BY shop_carts.user_id ORDER BY order_id DESC");
        $content_data['unpaid_users'] = $res->result_array();
		$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')) ;
		
		$data['content'] = $this->load->view('admin/users/unpaid_users', $content_data, TRUE);
		$this->load->view('admin/layout', $data);
	}
}