<?php
namespace Controllers;
// Контроллер для дисплея покупателей
class Cd extends Controller {

	public function __construct() {
		parent::__construct();
	}

	function receipt() {
		header('Pragma: no-cache');
		if(!$this->cd) {
			$this->cd=new \Models\Cd($this->db, $this->f3);
		}
		if($this->f3->get('GET.adv') && $this->f3->get('GET.ajax')) {
			$api=new \Controllers\Api();
			$advs=$api->model->advertising();
			if($advs['success']) {
				$this->f3->set('advs', $advs['advertising']);
			}
		}
		$this->f3->set('page_data', $this->cd->page_data('receipt'));
		echo \Template::instance()->render('cd_layout.htm');
		exit();
	}

	function pricechecker() {
		header('Pragma: no-cache');
		if(!$this->cd) {
			$this->cd=new \Models\Cd($this->db, $this->f3);
		}
		if($this->f3->get('GET.adv') && $this->f3->get('GET.ajax')) {
			$api=new \Controllers\Api();
			$advs=$api->model->advertising();
			if($advs['success']) {
				$this->f3->set('advs', $advs['advertising']);
			}
		}
		$pricechecker_settings=$this->f3->get('COOKIE.pricechecker_settings');
		$this->f3->set('pricechecker_settings', json_decode($pricechecker_settings, true));
		$this->f3->set('page_data', $this->cd->page_data('pricechecker'));
		echo \Template::instance()->render('cd_layout.htm');
		exit();
	}
}
