Advertisement
Guest User

Untitled

a guest
Jul 27th, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.88 KB | None | 0 0
  1. $expenses = $expense->dailyExpense();
  2. $income = $income->dailyIncome();
  3. return response()->json(['data' => ['expenses' => $expenses , 'income' => $income] , 'msg' => 'Daily Expense']);
  4.  
  5. public function dailyIncome()
  6. {
  7.  
  8. return $this->makeModel()
  9. ->select(DB::raw("sum(cost) as income"),"date")
  10. ->groupBy('date')
  11. ->get();
  12. }
  13.  
  14. public function dailyExpense()
  15. {
  16.  
  17. return $this->makeModel()
  18. ->select(DB::raw("sum(cost) as cost") , "date" , DB::raw("dayname(date) as calendar"))
  19. ->groupBy('date')
  20. ->get();
  21. }
  22.  
  23. $scope.genereateReport = function () {
  24.  
  25. $scope.choices = ['Daily', 'Monthly', 'Yearly'];
  26. $scope.$watch('selection', function (newVal, oldVal) {
  27. switch (newVal) {
  28. case 'Daily':
  29.  
  30. $scope.url = $scope.base_path + 'dailyExpenses';
  31. $http.get($scope.url).success(function (response) {
  32. $scope.expenses = response.data.expenses;
  33. $scope.income = response.data.income;
  34. $scope.totalExpenses = response.data.totalExpenses;
  35.  
  36.  
  37. });
  38.  
  39. $scope.displayedCollection = [].concat($scope.expenses,$scope.income);
  40. console.log("collection:" + $scope.displayedCollection);
  41. $scope.totalExpenses = [].concat($scope.$totalExpenses);
  42. // $scope.income = [].concat($scope.income);
  43. //
  44.  
  45. $scope.itemsByPage = 10;
  46. break;
  47. }
  48. );
  49. };
  50.  
  51. <tr>
  52. <th class="table-header-check">S.N</th>
  53. <th st-sort="date" class="table-header-repeat line-left minwidth-1">Date</th>
  54. <th st-sort="date" class="table-header-repeat line-left minwidth-1">Calandar</th>
  55. <th st-sort="cost" class="table-header-repeat line-left minwidth-1">
  56. Expense
  57. </th> <th st-sort="cost" class="table-header-repeat line-left minwidth-1">
  58. Income
  59. </th>
  60.  
  61. </tr>
  62.  
  63.  
  64. </thead>
  65. <tbody>
  66.  
  67. <tr data-ng-repeat="row in displayedCollection track by $index" >
  68. <td><% $index+1 %></td>
  69. <td><%row.date%></td>
  70. <td><%row.calendar%></td>
  71. <td><%row.cost%></td>
  72.  
  73. <td><%income['row.date']%></td>
  74.  
  75.  
  76. </tr>
  77. <tr>
  78. <td colspan="4">
  79. Total Expense: <%totalExpenses%>
  80. </td>
  81.  
  82.  
  83. </tr>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement