<?php namespace Pratik\Controllers;
use CodeIgniter\Controller;
use Pratik\Config\Ogrencigruplari_Config;
use Pratik\Models\Pratik_Model;
class Ogrencigruplari 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();
		$this->data['module'] = 'ogrencigruplari';
    }
	public function index()
	{	
		if($this->state === false ) $this->state =  $this->request->getPostget('state');	
		if($this->state===null) $this->state=1;
		$elements = new Ogrencigruplari_Config();
		$this->data['page_title']=t_('ogrencigruplari','dersliksate_'.$this->state);		
		$this->data['elements'] = $elements->basic;	
		$this->data['state'] = $this->state;
		$this->data['menu'] =array('ogrencigruplari','ogrencigrubusate_'.$this->state);		
		return view('Admin\ogrencigruplari\ogrencigruplari_list', array('data'=>$this->data));
	}
	public function setup()
	{
		$elements = new Ogrencigruplari_Config();
		$this->model->setupTable('ogrencigruplari',$elements->basic);
		$this->data['menu']=array('ogrencigruplari');
	}
	public function edit()
	{	
		$id =  $this->request->getPostget('id');
		$elements = new Ogrencigruplari_Config();
		//$model->setupTable('users',$elements->basic);
		$this->data['basic'] = $this->model->getBasic('ogrencigruplari', $id, $elements->basic,'',true );
		if($id==0)
		{
			$this->data['basic']['id']['val']=0;
			$this->data['basic']['ad']['val']=t_('Yeni Kayıt Grubu');
			
		}
		$this->data['metas'] = $this->model->getMetas($id, 'ogrencigruplari', "",$elements->metas, 'tr_TR', 'meta', true, false);
		$this->data['ogrenciler'] = $this->model->getTableRows('ogrenciler', "ogrenci_grubu=".(int)$id);
		if(!$this->data['ogrenciler']) $this->data['ogrenciler']=array();
		$this->data['page_title']=t_('Kayıt Grupları');		
		$this->data['menu']=array('ogrencigruplari','ogrencigrubu_edit');
		return view('Admin\ogrencigruplari\ogrencigruplari_edit', array('data'=>$this->data));
	}
	//--------------------------------------------------------------------
}
