public function totalMonthlyExpenses(Request $request, $expenseId = null)
 {
     $query = "select sum(cost) as Total,\n                      DATE_FORMAT( created_at , \"%M\") as Month\n                      from trackedexpenses\n                      where MONTH(created_at) in(1,2,3,4,5,6,7,8,9,10,11,12)\n                            ";
     if (isset($expenseId)) {
         $query .= "AND trackedexpenses.expense_id = " . $expenseId;
     }
     $query .= "and DATE_FORMAT( created_at , \"%Y\") = 2016";
     $query .= " group by MONTH(created_at)";
     return ['totalMonthly' => DB::select($query), 'expenses' => Expense::all(['name', 'id'])];
 }
 /**
  * Homepage Method
  * @method index
  * @return view The homepage HTML.
  */
 public function index()
 {
     // TODO: optimize these queries.
     // TODO: Decide whether or now to show a monthly earnings, instead of
     // just a weekly breakdown of the totals.
     $data['incomes'] = Income::all()->sortByDesc('amount');
     $data['expenses'] = Expense::all()->sortByDesc('amount');
     $data['totalIncome'] = DB::table('incomes')->sum('amount') / 4;
     $data['totalExpenses'] = DB::table('expenses')->sum('amount') / 4;
     $data['weeklyWorth'] = $data['totalIncome'] - $data['totalExpenses'];
     return view('index', $data);
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $expenses = Expense::all()->load("expensesTransactions");
     return $expenses;
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $expenses = Expense::all();
     return view('expenses.index', compact('expenses'));
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $expenses = Expense::all()->sortByDesc('amount');
     return view('expenses/index')->with('expenses', $expenses);
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     return Expense::all();
 }
 /**
  * Display a listing of the resource.
  *
  * @return Illuminate\Http\JsonResponse
  */
 public function index()
 {
     $expenses = Expense::all();
     return response()->json($expenses);
 }
Example #8
0
 public function generate()
 {
     ini_set("max_execution_time", 0);
     if (Auth::user()->role == "Project Manager") {
         $activities = Activity::whereIn('action', array('Created', 'Deleted', 'Updated'))->where(function ($query) {
             return $query->where('action', '!=', 'Created')->orWhere('type', '!=', 'Deliverable');
         })->where('user_id', Auth::user()->id)->get();
         $projects = Project::where('user_id', Auth::user()->id)->get();
         $projectids = array_pluck($projects, 'id');
         $milestones = Milestone::whereIn('project_id', $projectids)->get();
         $accomplishments = Accomplishment::whereIn('project_id', $projectids)->get();
         $issues = Issue::whereIn('project_id', $projectids)->get();
         $risks = Risk::whereIn('project_id', $projectids)->get();
         $expenses = Expense::whereIn('project_id', $projectids)->get();
         $actions = Action::whereIn('project_id', $projectids)->get();
         $deliverables = Deliverable::whereIn('project_id', $projectids)->get();
         $business_project_team_members = BusinessProjectTeamMember::whereIn('project_id', $projectids)->get();
         $technical_project_team_members = TechnicalProjectTeamMember::whereIn('project_id', $projectids)->get();
         $support_team_members = SupportTeamMember::whereIn('project_id', $projectids)->get();
         return view('audit.generate', compact('activities', 'projects', 'milestones', 'accomplishments', 'issues', 'risks', 'expenses', 'actions', 'deliverables', 'business_project_team_members', 'technical_project_team_members', 'support_team_members'));
     } elseif (Auth::user()->role == "System Administrator") {
         $activities = Activity::whereIn('action', array('Created', 'Deleted', 'Updated'))->where(function ($query) {
             return $query->where('action', '!=', 'Created')->orWhere('type', '!=', 'Deliverable');
         })->get();
         $projects = Project::all();
         $milestones = Milestone::all();
         $accomplishments = Accomplishment::all();
         $issues = Issue::all();
         $risks = Risk::all();
         $users = User::all();
         $expenses = Expense::all();
         $actions = Action::all();
         $deliverables = Deliverable::all();
         $business_project_team_members = BusinessProjectTeamMember::all();
         $technical_project_team_members = TechnicalProjectTeamMember::all();
         $support_team_members = SupportTeamMember::all();
         return view('audit.generate', compact('activities', 'projects', 'milestones', 'accomplishments', 'issues', 'risks', 'users', 'expenses', 'actions', 'deliverables', 'business_project_team_members', 'technical_project_team_members', 'support_team_members'));
     } else {
         flash()->error('You are not authorized to proceed.');
         return redirect()->action('ProjectsController@index');
     }
 }