<?php

class BudgetOperationHistoryController extends BaseController {

	/**
	 * Constructor
	 */
	public function __construct() {
		// Establish Filters
		$this->beforeFilter('auth');

		if (Auth::check()) {
			$this->user			 = Auth::user();
			$this->projects	 = $this->user->budgetProjects;
		}
		$this->projectPrefix = 'budget';
		parent::__construct();
	}
  
  // история операции
  public function getHistory() {
    $input = Input::all();
    
    $operation = BudgetOperation::find( $input['operationId'] ); 
    if ($operation == null || !is_numeric($input['operationId'])) {
			$response = array('status' => 'fail', 'message' => 'Операция не найдена');
			return Response::json($response);
		}

    $log = BudgetOperationHistory::whereOperationId($operation->id)
                                   ->with('user')
                                   ->with('project')
                                   ->orderBy('created_at', 'DESC')
                                   ->get();
    
    $response = array(
				'status' => 'success',
        'log'    => $log
		);
		return Response::json($response);
  }
  
  
}