<?php

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

class Selling extends MY_Controller {

	/**
	 * Index Page for this controller.
	 *
	 * Maps to the following URL
	 * 		http://example.com/index.php/welcome
	 *	- or -
	 * 		http://example.com/index.php/welcome/index
	 *	- or -
	 * Since this controller is set as the default controller in
	 * config/routes.php, it's displayed at http://example.com/
	 *
	 * So any other public methods not prefixed with an underscore will
	 * map to /index.php/welcome/<method_name>
	 * @see https://codeigniter.com/user_guide/general/urls.html
	 */
	public function index()
	{
		if (! $this->uri->segment(3)) {
			echo "<h1>Access Denied</h1>";
			exit;
		}
	}

	public function promote()
	{
//		if (! $this->uri->segment(3)) {
//			echo "<h1>Access Denied</h1>";
//			exit;
//		}
//		$webinar_token = $this->uri->segment(3);
//		$this->load->model('Webinar_model', 'webinar');
//		$webinar = $this->webinar->token_search($webinar_token);
//		if (! $webinar) {
//			echo "<h1>Invalid access token</h1>";
//			exit;
//		}
//		$this->load->model('Promotion_model', 'promotion');
//		$promotion = $this->promotion->one($webinar['promotion_id']);
//		\Stripe\Stripe::setApiKey($this->config->item('stripe')['secret_key']);

		$this->load->view('selling/index', [
			'base_url' => base_url(),
			'page_title' => 'NLP Academy - Webinar page - ',
			'vendors' => [
				'css' => [
				],
				'js' => [
					'https://player.vimeo.com/api/player.js',
				],
			],
			'class' => $this->router->class,
			'module' => '',
			'stripe' => $this->config->item('stripe')['publishable_key'],
			'promotion' => [
			],
		]);
	}

	public function confirm_payment()
	{
//		if (! $this->uri->segment(3)) {
//			echo "<h1>Access Denied</h1>";
//			exit;
//		}
//		$webinar_token = $this->uri->segment(3);
//		$this->load->model('Webinar_model', 'webinar');
//		$webinar = $this->webinar->token_search($webinar_token);
//		if (! $webinar) {
//			echo "<h1>Invalid access token</h1>";
//			exit;
//		}
//		$this->load->model('Promotion_model', 'promotion');
//		$promotion = $this->promotion->one($webinar['promotion_id']);

		$this->load->view('selling/confirm_payment', [
			'base_url' => base_url(),
			'page_title' => 'NLP Academy - Webinar page - ',
			'vendors' => [
				'css' => [
				],
				'js' => [
					'https://player.vimeo.com/api/player.js',
				],
			],
			'class' => $this->router->class,
			'module' => '',
			'stripe' => $this->config->item('stripe')['publishable_key'],
			'promotion' => [
			],
		]);
	}

	public function success()
	{
		$this->load->view('selling/success', [
			'base_url' => base_url(),
			'page_title' => 'NLP Academy - Webinar page - ',
			'vendors' => [
				'css' => [
				],
				'js' => [
				],
			],
			'class' => $this->router->class,
			'module' => '',
		]);
	}

	public function fail()
	{
		$this->load->view('selling/fail', [
			'base_url' => base_url(),
			'page_title' => 'NLP Academy - Webinar page - ',
			'vendors' => [
				'css' => [
				],
				'js' => [
				],
			],
			'class' => $this->router->class,
			'module' => '',
		]);
	}

}
