<?php
/**
 * AJAX Row Details
 * @copyright 0arkcode
 * @author 0arkcode@gmail.com
 * @license 0arkcode
 * 
 * Errors:
 * AJAX_ADM_R_D_TABLE - 
 */

        $table = $_REQUEST['table'];
        
        $admin = new admin;
        
        if( stristr( $_SERVER['HTTP_REFERER'] , '?' ) ) list( $admin_url ) = explode("?",$_SERVER['HTTP_REFERER']);
        else $admin_url = $_SERVER['HTTP_REFERER'];
        
        $admin->url = @end( explode( "/" , $admin_url ) );
        
        if( !in_array( $table , row_details::$hidden_map )  ){
            
            $row_details = new row_details( $table , ( ( $table=='user' AND core::$i->id==2 ) ? 1 : core::$i->id ) );
            
            if( $row_details->all_data ){
                
                $tpl->assign(array(
                    'details' => $row_details->html_rows,
                    'details_all_data' => $row_details->all_data,
                    'options' => $row_details->options
                ));
                
                js::$i->setJSON( 'options' , ( $row_details->options ? $row_details->options : false ) );
                js::$i->setJSON( 'title' , l('Szczegóły') );
                js::$i->setJSON( 'html' , $tpl->fetch('admin/row_details_list.tpl') );
                js::$i->setJSON( 'modal_no' , l('Zamknij') );
                
                js::$i->setJSON( 'status' , 'ok' );
                
            } else {
                
                js::$i->setJSON( 'title' , l('Error') );
                js::$i->setJSON( 'status' , 'err' );
                js::$i->setJSON( 'msg' , l('Details not found') );
                
            }
            
            
        } else {

            js::$i->setJSON( 'title' , l('Error') );
            js::$i->setJSON( 'status' , 'err' );
            js::$i->setJSON( 'msg' , l('Incorrect request AJAX_ADM_R_D_TABLE') );
            
        }

?>