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

class MyqrController extends CI_Controller {

    public function __construct()
	{
		parent::__construct();		
		$this->load->model('GuestModel');
		$this->load->model('PrepackageModel');
		$this->load->model('SiteModel');		
		$this->load->model('SiteDataModel');
    }
	public function index()
	{
        $userdata = $this->session->userdata('makeabl2020');
        if (empty($userdata) || !isset($userdata["id"]))
			redirect('login', 'refresh');
        
        $data['guest_detail'] = $this->GuestModel->get_row($userdata['id']);
        $data['guest_row'] = $this->GuestModel->get_guest_row($userdata['id']);
        $data['guest_detail']['qr_token'] = $data['guest_row']['qr_token'];
        
        $data['title'] = 'QR | MAKEABL';

        $data['prepackage_list'] = $this->PrepackageModel->get_qrscan_prepackage_rows(" where ppqt.token = ppht.token and pt.price > 0 order by ppqt.id desc" , $userdata['id']);

        $data['header_title'] = 'My QR';


        // $this->SiteDataModel->insert_row();

        $this->load->view('template/header', $data);
		$this->load->view('template/sidebar', $data);
		$this->load->view('myqr', $data);
		$this->load->view('template/footer', $data);		
	}

	public function myqrscan()
	{
		$userdata = $this->session->userdata('makeabl2020');
        if (empty($userdata) || !isset($userdata["id"]))
			redirect('login', 'refresh');
        
        $data['guest_detail'] = $this->GuestModel->get_row($userdata['id']);
        $data['guest_row'] = $this->GuestModel->get_guest_row($userdata['id']);
        $data['guest_detail']['qr_token'] = $data['guest_row']['qr_token'];
        
        $data['title'] = 'Scan Your QR Code | MAKEABL';

        $data['prepackage_list'] = $this->PrepackageModel->get_qrscan_prepackage_rows(" where ppqt.token = ppht.token and pt.price > 0 order by ppqt.id desc" , $userdata['id']);

        $data['header_title'] = 'My QR';

        $this->load->view('myqrscan', $data);
	}
}