<?php
    
    global $tpl;  

    switch( core::$i->method )
    {
        case 'save':
            
            if( !empty($_REQUEST['nazwa']) and core::$i->id AND db::$i->row("SELECT 1 FROM `user` WHERE `pass`='".( esc( user::pass_encoder( $_REQUEST['password'] ) ) )."' AND `mode`='therapist'") )
            {
                db::$i->update('kryteria',array('nazwa'=>esc($_REQUEST['nazwa'])),core::$i->id);
                js::$i->setJSON(array(
                    'status' => true,
                    'refresh' => true
                ));
            }
            

        

        break;
        
        default:
        
            $tpl->assign(array(
                'data' => kryteria::get( core::$i->id )
            ));
        
            js::$i->setJSON(array(   
                'status' => true,
                'html' => $tpl->fetch('ajax/' . core::$i->mode . '/' . core::$i->function . '.tpl' )
            ));
            
        break;
    }

?>