Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $expenses = $expense->dailyExpense();
- $income = $income->dailyIncome();
- return response()->json(['data' => ['expenses' => $expenses , 'income' => $income] , 'msg' => 'Daily Expense']);
- public function dailyIncome()
- {
- return $this->makeModel()
- ->select(DB::raw("sum(cost) as income"),"date")
- ->groupBy('date')
- ->get();
- }
- public function dailyExpense()
- {
- return $this->makeModel()
- ->select(DB::raw("sum(cost) as cost") , "date" , DB::raw("dayname(date) as calendar"))
- ->groupBy('date')
- ->get();
- }
- $scope.genereateReport = function () {
- $scope.choices = ['Daily', 'Monthly', 'Yearly'];
- $scope.$watch('selection', function (newVal, oldVal) {
- switch (newVal) {
- case 'Daily':
- $scope.url = $scope.base_path + 'dailyExpenses';
- $http.get($scope.url).success(function (response) {
- $scope.expenses = response.data.expenses;
- $scope.income = response.data.income;
- $scope.totalExpenses = response.data.totalExpenses;
- });
- $scope.displayedCollection = [].concat($scope.expenses,$scope.income);
- console.log("collection:" + $scope.displayedCollection);
- $scope.totalExpenses = [].concat($scope.$totalExpenses);
- // $scope.income = [].concat($scope.income);
- //
- $scope.itemsByPage = 10;
- break;
- }
- );
- };
- <tr>
- <th class="table-header-check">S.N</th>
- <th st-sort="date" class="table-header-repeat line-left minwidth-1">Date</th>
- <th st-sort="date" class="table-header-repeat line-left minwidth-1">Calandar</th>
- <th st-sort="cost" class="table-header-repeat line-left minwidth-1">
- Expense
- </th> <th st-sort="cost" class="table-header-repeat line-left minwidth-1">
- Income
- </th>
- </tr>
- </thead>
- <tbody>
- <tr data-ng-repeat="row in displayedCollection track by $index" >
- <td><% $index+1 %></td>
- <td><%row.date%></td>
- <td><%row.calendar%></td>
- <td><%row.cost%></td>
- <td><%income['row.date']%></td>
- </tr>
- <tr>
- <td colspan="4">
- Total Expense: <%totalExpenses%>
- </td>
- </tr>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement