コード例 #1
0
 public function Dashboard()
 {
     $response = new ServiceResponse();
     $model = new stdClass();
     $totalUser = UserEntity::where("IsDeleted", 0)->count();
     //$this->GetEntityCount(new UserEntity(),"");
     $totalEarning = DB::select("SELECT SUM(pph.SubscriptionAmount) AS Amount, YEAR(PaymentDate) AS `Year` FROM paymentplanshistory pph where IsTrial = 0 GROUP BY YEAR(PaymentDate)");
     //PaymentPlansHistoryEntity::all()->sum("SubscriptionAmount");
     $totalPaidUsers = PaymentPlansHistoryEntity::where("IsTrial", 0)->where("isActive", 1)->count();
     $totalTrialUsers = PaymentPlansHistoryEntity::where("IsTrial", 1)->where("isActive", 1)->count();
     $lastTenUser = $this->RunQueryStatement("SELECT * FROM users ORDER BY CreatedDate DESC LIMIT 10", Constants::$QueryType_Select);
     $lastTenPayment = $this->RunQueryStatement("SELECT u.UserID,u.FirstName,u.LastName,u.City ,ph.IsActive,u.Mobile , ph.Amount ,ph.SubscriptionAmount,ph.PaymentDate FROM paymentplanshistory ph\n        LEFT JOIN users u ON u.UserID = ph.UserID\n        WHERE  ph.IsTrial = 0\n        ORDER BY PaymentDate DESC LIMIT 10", Constants::$QueryType_Select);
     if ($totalEarning && count($totalEarning) > 0) {
         foreach ($totalEarning as $perYear) {
             $perYear->Amount = Common::moneyFormatIndia((int) $perYear->Amount);
         }
     } else {
         $totalEarning = array();
     }
     //$totalEarning = Common::moneyFormatIndia((int)$totalEarning);
     $model->TotalUsers = $totalUser;
     $model->TotalEarning = $totalEarning;
     $model->TotalPaidUsers = $totalPaidUsers;
     $model->TotalTrialUsers = $totalTrialUsers;
     $model->LastTenUser = $lastTenUser;
     $model->LastTenPayment = $lastTenPayment;
     $response->Data = $model;
     $response->IsSuccess = true;
     return $response;
 }