Esempio n. 1
0
 public function store($lcnsTypes, $userStatus, $reqParams, $pcName, $accountParams)
 {
     foreach ($lcnsTypes as $typeId) {
         if (LicenseType::find($typeId)->name == 'SABA Publisher') {
             $this->pc_name = $pcName;
             $return = $this->validation();
             if ($return) {
                 return Redirect::back()->withErrors($return)->with('status', $userStatus)->withInput();
             }
         }
     }
     if ($userStatus == 'existing') {
         $account = Account::where('username', $accountParams['username'])->first();
         $this->account_id = $account->id;
         $this->dbStore($reqParams);
     } else {
         $account = Account::withParams($accountParams);
         if ($return = $account->validation()) {
             return Redirect::back()->withErrors($return)->with('status', $userStatus)->withInput();
         }
         $account->store();
         $this->account_id = $account->id;
         $account->created_from = $this->dbStore($reqParams);
         $account->save();
     }
     //license types to be added
     foreach ($lcnsTypes as $lcnsType) {
         if (!in_array($lcnsType, $this->licenseTypes()->lists('id'))) {
             $this->licenseTypes()->attach($lcnsType);
         }
     }
     //license types to be removed
     foreach ($this->licenseTypes()->lists('id') as $id) {
         if (!in_array($id, $lcnsTypes)) {
             $this->licenseTypes()->detach($id);
         }
     }
     $success = Lang::get('admin/request/message.success.create');
     return array('success' => 1, 'message' => $success, 'type' => $this->type);
 }
Esempio n. 2
0
 public function populateDashboard($roleId)
 {
     $licenses = array();
     $lcnsTypes = LicenseType::lists('name', 'id');
     //get the total amount of licenses
     $totalAlloc = $this->countTotalByRole($roleId);
     $totalUsed = $this->countUsedByRole($roleId);
     $totalRemaining = $this->countRemainingByRole($roleId);
     foreach ($lcnsTypes as $key => $type) {
         $allocated = $this->countTotalByType($key, $roleId);
         $used = $this->countUsedByType($key, $roleId);
         $remaining = $this->countRemainingByType($key, $roleId);
         $licenses[$key] = new \stdClass();
         $licenses[$key]->name = $type;
         $licenses[$key]->allocated = $allocated;
         $licenses[$key]->used = $used;
         $licenses[$key]->remaining = $remaining;
         //get percentages for chart
         if ($totalAlloc == 0) {
             $percentAlloc = 25;
         } else {
             $percentAlloc = $licenses[$key]->allocated / $totalAlloc * 100;
         }
         $data = array('allocated' => $percentAlloc);
         $licenses[$key]->percentages = new \ArrayObject($data);
     }
     return $licenses;
 }