<?php namespace Pratik\Controllers;

use CodeIgniter\Controller;
use Pratik\Config\Indirimler_Config;
use Pratik\Models\Pratik_Model;

class Indirimler extends Controller
{
	public $data = array();
	public $model ;
	public $state=false ;
    function __construct()
	{
        $this->model = new Pratik_Model();
        $this->session = \Config\Services::session();
		$this->request = \Config\Services::request();
    }
	public function index()
	{	
		if($this->state === false ) $this->state =  $this->request->getPostget('state');	
		if($this->state===null) $this->state=1;
		$elements = new indirimler_Config();
		$this->data['page_title']=t_('indirimler','indirimsate_'.$this->state);		
		$this->data['elements'] = $elements->basic;	
		$this->data['state'] = $this->state;
		$this->data['menu'] =array('indirimler','indirimsate_'.$this->state);		
		return view('Admin\indirimler\indirimler_list', array('data'=>$this->data));
	}
	public function setup()
	{
		$elements = new indirimler_Config();
		$this->model->setupTable('indirimler',$elements->basic);
		$this->data['menu']=array('indirimler');
	}
	public function edit()
	{	
		$id =  $this->request->getPostget('id');
		$elements = new Indirimler_Config();

		$this->data['basic'] = $this->model->getBasic('indirimler', $id, $elements->basic,'',true );
		if($id==0)
		{
			$this->data['basic']['id']['val']=0;
			$this->data['basic']['ad']['val']=t_('Yeni İndirim');
			
		}
		$this->data['metas'] = $this->model->getMetas($id, 'indirimler', "",$elements->metas, 'tr_TR', 'meta', true, false);
		$this->data['page_title']=t_('İndirimler');		
		$this->data['menu']=array('indirimler','indirim_edit');
		return view('Admin\indirimler\indirim_edit', array('data'=>$this->data));
	}

	//--------------------------------------------------------------------

}
