<?php 
$controller = 'ExpensesConfig';
$action = '';
if(isset($_POST['action'])){
    $action = $_POST['action'];
    if (isset($_POST['id'])) {$id = $_POST['id'];}
}elseif(isset($_GET['action'])){
    $action = $_GET['action'];
    if (isset($_GET['id'])) {$id = $_GET['id'];}
}

include $_SERVER["DOCUMENT_ROOT"].'/app/include/bootstrap.php';

$_expenseConfig = new ExpenseConfigRepository();

switch($action){        
    case 'export':
        switch($_GET['flag']){
            case 'pdf':
                $pdf = new ExpenseConfigPDF($id);
                break;
            }   
        break;
        
    case 'ajax':
        $ajaxExpenseConfig = new ExpenseConfigAjax();
        $json = $ajaxExpenseConfig->getResponse($_POST['request'],$_POST);
        
        echo json_encode($json);
        break;       
    
    default:      
        $_data = $_expenseConfig->getFixedExpensesList();
        $_expensesList =  $_data['fixed_expense_list'];
        $_storeList =  $_data['store_list'];
        $_dataConfig =  $_data['data_config'];
        
        $vista = 'ExpenseConfig.php';
        include $root.'/View/Template.php';
        break;
}