/**
  * Remove the specified resource from storage.
  * DELETE /branch/{id}
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $license = License::find($id);
     if ($license->status == 'used') {
         return Redirect::to('/licenses/' . $id)->with('alert', ['type' => 'danger', 'message' => 'No puedes borrar una licencia en uso.']);
     } else {
         License::destroy($id);
         return Redirect::to('/licenses')->with('alert', ['type' => 'success', 'message' => 'El libro ha sido borrado.']);
     }
 }
 public function postDeleteUsage($id)
 {
     // Get Usage
     $usage = LicensesUses::find($id);
     // Get License
     $license = License::find($usage->license_id);
     // Delete Usage
     $usage->delete();
     Session::flash('alert_message', '<strong>Done!</strong> You successfully have deleted a license usage.');
     return Redirect::to("admin/licenses/usage/{$license->license_key}");
 }
 public function getAcceptAsset($logID = null)
 {
     if (is_null($findlog = Actionlog::find($logID))) {
         // Redirect to the asset management page
         return Redirect::to('account')->with('error', Lang::get('admin/hardware/message.does_not_exist'));
     }
     // Asset
     if ($findlog->asset_id != '' && $findlog->asset_type == 'hardware') {
         $item = Asset::find($findlog->asset_id);
         // software
     } elseif ($findlog->asset_id != '' && $findlog->asset_type == 'software') {
         $item = License::find($findlog->asset_id);
         // accessories
     } elseif ($findlog->accessory_id != '') {
         $item = Accessory::find($findlog->accessory_id);
     }
     // Check if the asset exists
     if (is_null($item)) {
         // Redirect to the asset management page
         return Redirect::to('account')->with('error', Lang::get('admin/hardware/message.does_not_exist'));
     }
     return View::make('frontend/account/accept-asset', compact('item'))->with('findlog', $findlog);
 }
Exemple #4
0
 /**
  * Handle depreciation
  */
 public function depreciate()
 {
     $depreciation_id = License::find($this->license_id)->depreciation_id;
     if ($depreciation_id) {
         $depreciation_term = Depreciation::find($depreciation_id)->months;
         if ($depreciation_term > 0) {
             $purchase_date = strtotime($this->purchase_date);
             $todaymonthnumber = date("Y") * 12 + (date("m") - 1);
             //calculate the month number for today as YEAR*12 + (months-1) - number of months since January year 0
             $purchasemonthnumber = date("Y", $purchase_date) * 12 + (date("m", $purchase_date) - 1);
             //purchase date calculated similarly
             $diff_months = $todaymonthnumber - $purchasemonthnumber;
             // fraction of value left
             $current_value = round(($depreciation_term - $diff_months) / $depreciation_term * $this->purchase_cost, 2);
             if ($current_value < 0) {
                 $current_value = 0;
             }
             return $current_value;
         } else {
             return $this->purchase_cost;
         }
     } else {
         return $this->purchase_cost;
     }
 }
 public function getAcceptAsset($logID = null)
 {
     if (is_null($findlog = Actionlog::find($logID))) {
         // Redirect to the asset management page
         return Redirect::to('account')->with('error', Lang::get('admin/hardware/message.does_not_exist'));
     }
     $user = Sentry::getUser();
     if ($user->id != $findlog->checkedout_to) {
         return Redirect::to('account/view-assets')->with('error', Lang::get('admin/users/message.error.incorrect_user_accepted'));
     }
     // Asset
     if ($findlog->asset_id != '' && $findlog->asset_type == 'hardware') {
         $item = Asset::find($findlog->asset_id);
         // software
     } elseif ($findlog->asset_id != '' && $findlog->asset_type == 'software') {
         $item = License::find($findlog->asset_id);
         // accessories
     } elseif ($findlog->accessory_id != '') {
         $item = Accessory::find($findlog->accessory_id);
     }
     // Check if the asset exists
     if (is_null($item)) {
         // Redirect to the asset management page
         return Redirect::to('account')->with('error', Lang::get('admin/hardware/message.does_not_exist'));
     } else {
         if (!Company::isCurrentUserHasAccess($item)) {
             return Redirect::route('requestable-assets')->with('error', Lang::get('general.insufficient_permissions'));
         } else {
             return View::make('frontend/account/accept-asset', compact('item'))->with('findlog', $findlog);
         }
     }
 }