Exemple #1
0
 public function update($id, ComponentRequest $request)
 {
     $component = Component::findOrFail($id);
     $component->update($request->all());
     Session()->flash('flash_message', 'Component has been updated!');
     return redirect('components');
 }
Exemple #2
0
 public function edit($id)
 {
     $task = Task::findOrFail($id);
     $components = Component::lists('name_en', 'id');
     $modules = Module::where('component_id', '=', $task->component_id)->lists('name_en', 'id');
     return view('tasks.edit', compact('task', 'modules', 'components'));
 }
 private function updateId()
 {
     $components = Component::all();
     foreach ($components as $component) {
         $new = Component::find($component->id);
         $new->id = Component::get_uid();
         $new->save();
     }
 }
Exemple #4
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     if ($this->confirm("\n****************************************************\nTHIS WILL DELETE ALL OF THE DATA IN YOUR DATABASE. \nThere is NO undo. This WILL destroy ALL of your data. \n****************************************************\n\nDo you wish to continue? No backsies! [y|N]")) {
         if ($this->option('soft')) {
             Accessory::getQuery()->delete();
             Asset::getQuery()->delete();
             Category::getQuery()->delete();
             Company::getQuery()->delete();
             Component::getQuery()->delete();
             Consumable::getQuery()->delete();
             Depreciation::getQuery()->delete();
             License::getQuery()->delete();
             LicenseSeat::getQuery()->delete();
             Location::getQuery()->delete();
             Manufacturer::getQuery()->delete();
             AssetModel::getQuery()->delete();
             Statuslabel::getQuery()->delete();
             Supplier::getQuery()->delete();
             Group::getQuery()->delete();
             DB::statement('delete from accessories_users');
             DB::statement('delete from asset_logs');
             DB::statement('delete from asset_maintenances');
             DB::statement('delete from asset_uploads');
             DB::statement('delete from consumables_users');
             DB::statement('delete from custom_field_custom_fieldset');
             DB::statement('delete from custom_fields');
             DB::statement('delete from custom_fieldsets');
             DB::statement('delete from components_assets');
             DB::statement('delete from password_resets');
             DB::statement('delete from requested_assets');
             DB::statement('delete from requests');
             DB::statement('delete from throttle');
             DB::statement('delete from users_groups');
             DB::statement('delete from users WHERE id!=1');
         } else {
             \DB::statement('drop table IF EXISTS accessories_users');
             \DB::statement('drop table IF EXISTS accessories');
             \DB::statement('drop table IF EXISTS asset_logs');
             \DB::statement('drop table IF EXISTS asset_maintenances');
             \DB::statement('drop table IF EXISTS asset_uploads');
             \DB::statement('drop table IF EXISTS assets');
             \DB::statement('drop table IF EXISTS categories');
             \DB::statement('drop table IF EXISTS companies');
             \DB::statement('drop table IF EXISTS consumables_users');
             \DB::statement('drop table IF EXISTS consumables');
             \DB::statement('drop table IF EXISTS custom_field_custom_fieldset');
             \DB::statement('drop table IF EXISTS custom_fields');
             \DB::statement('drop table IF EXISTS custom_fieldsets');
             \DB::statement('drop table IF EXISTS depreciations');
             \DB::statement('drop table IF EXISTS groups');
             \DB::statement('drop table IF EXISTS history');
             \DB::statement('drop table IF EXISTS components');
             \DB::statement('drop table IF EXISTS components_assets');
             \DB::statement('drop table IF EXISTS license_seats');
             \DB::statement('drop table IF EXISTS licenses');
             \DB::statement('drop table IF EXISTS locations');
             \DB::statement('drop table IF EXISTS manufacturers');
             \DB::statement('drop table IF EXISTS models');
             \DB::statement('drop table IF EXISTS migrations');
             \DB::statement('drop table IF EXISTS password_resets');
             \DB::statement('drop table IF EXISTS requested_assets');
             \DB::statement('drop table IF EXISTS requests');
             \DB::statement('drop table IF EXISTS settings');
             \DB::statement('drop table IF EXISTS status_labels');
             \DB::statement('drop table IF EXISTS suppliers');
             \DB::statement('drop table IF EXISTS throttle');
             \DB::statement('drop table IF EXISTS users_groups');
             \DB::statement('drop table IF EXISTS users');
         }
     }
 }
 /**
  * Return JSON data to populate the components view,
  *
  * @author [A. Gianotto] [<*****@*****.**>]
  * @see ComponentsController::getView() method that returns the view.
  * @since [v3.0]
  * @param int $componentId
  * @return string JSON
  */
 public function getDataView($componentId)
 {
     //$component = Component::find($componentID);
     $component = Component::with('assets')->find($componentId);
     if (!Company::isCurrentUserHasAccess($component)) {
         return ['total' => 0, 'rows' => []];
     }
     $rows = array();
     foreach ($component->assets as $component_assignment) {
         $rows[] = array('name' => (string) link_to('/hardware/' . $component_assignment->id . '/view', e($component_assignment->showAssetName())), 'qty' => e($component_assignment->pivot->assigned_qty), 'created_at' => $component_assignment->created_at->format('Y-m-d H:i:s') == '-0001-11-30 00:00:00' ? '' : $component_assignment->created_at->format('Y-m-d H:i:s'));
     }
     $componentCount = $component->assets->count();
     $data = array('total' => $componentCount, 'rows' => $rows);
     return $data;
 }
 public function search(Request $request)
 {
     $arr = [];
     if ($request->has('q')) {
         $q = $request->input('q');
         $branchid = $request->input('branchid');
         $components = Component::where('descriptor', 'like', '%' . $q . '%')->orderBy('descriptor')->get(['descriptor', 'id']);
         foreach ($components as $component) {
             array_push($arr, ['table' => 'component', 'item' => $component->descriptor, 'id' => strtolower($component->id)]);
         }
         $compcats = Compcat::where('descriptor', 'like', '%' . $q . '%')->orderBy('descriptor')->get(['descriptor', 'id']);
         foreach ($compcats as $compcat) {
             array_push($arr, ['table' => 'compcat', 'item' => $compcat->descriptor, 'id' => strtolower($compcat->id)]);
         }
         $expenses = Expense::where('descriptor', 'like', '%' . $q . '%')->orderBy('descriptor')->get(['descriptor', 'id']);
         foreach ($expenses as $expense) {
             array_push($arr, ['table' => 'expense', 'item' => $expense->descriptor, 'id' => strtolower($expense->id)]);
         }
         $expscats = Expscat::where('descriptor', 'like', '%' . $q . '%')->orderBy('descriptor')->get(['descriptor', 'id']);
         foreach ($expscats as $expscat) {
             array_push($arr, ['table' => 'expscat', 'item' => $expscat->descriptor, 'id' => strtolower($expscat->id)]);
         }
         $suppliers = Supplier::where('descriptor', 'like', '%' . $q . '%')->where('branchid', $branchid)->orderBy('descriptor')->get(['descriptor', 'id']);
         foreach ($suppliers as $supplier) {
             array_push($arr, ['table' => 'supplier', 'item' => $supplier->descriptor, 'id' => strtolower($supplier->id)]);
         }
         //$payments = ['110A573E855511E68FF47E841D02B37D'=>'cash', '19ADA60B855511E68FF47E841D02B37D'=>'check'];
         $payments = ['c' => 'cash', 'k' => 'check'];
         $s = preg_grep("/^" . strtolower($q) . "/", $payments);
         if ($s) {
             $k = key($s);
             array_push($arr, ['table' => 'payment', 'item' => ucwords($s[$k]), 'id' => strtolower($k)]);
         }
     }
     //return $arr;
     if ($request->ajax()) {
         return $arr;
     } else {
         return abort('404');
     }
 }
Exemple #7
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $force = $this->option('force');
     if ($this->confirm("\n****************************************************\nTHIS WILL PURGE ALL SOFT-DELETED ITEMS IN YOUR SYSTEM. \nThere is NO undo. This WILL permanently destroy \nALL of your deleted data. \n****************************************************\n\nDo you wish to continue? No backsies! [y|N]") || $force == 'true') {
         /**
          * Delete assets
          */
         $assets = Asset::whereNotNull('deleted_at')->withTrashed()->get();
         $assetcount = $assets->count();
         $this->info($assets->count() . ' assets purged.');
         $asset_assoc = 0;
         $asset_maintenances = 0;
         foreach ($assets as $asset) {
             $this->info('- Asset "' . $asset->showAssetName() . '" deleted.');
             $asset_assoc += $asset->assetlog()->count();
             $asset->assetlog()->forceDelete();
             $asset_maintenances += $asset->assetmaintenances()->count();
             $asset->assetmaintenances()->forceDelete();
             $asset->forceDelete();
         }
         $this->info($asset_assoc . ' corresponding log records purged.');
         $this->info($asset_maintenances . ' corresponding maintenance records purged.');
         $locations = Location::whereNotNull('deleted_at')->withTrashed()->get();
         $this->info($locations->count() . ' locations purged.');
         foreach ($locations as $location) {
             $this->info('- Location "' . $location->name . '" deleted.');
             $location->forceDelete();
         }
         $accessories = Accessory::whereNotNull('deleted_at')->withTrashed()->get();
         $accessory_assoc = 0;
         $this->info($accessories->count() . ' accessories purged.');
         foreach ($accessories as $accessory) {
             $this->info('- Accessory "' . $accessory->name . '" deleted.');
             $accessory_assoc += $accessory->assetlog()->count();
             $accessory->assetlog()->forceDelete();
             $accessory->forceDelete();
         }
         $this->info($accessory_assoc . ' corresponding log records purged.');
         $consumables = Consumable::whereNotNull('deleted_at')->withTrashed()->get();
         $this->info($consumables->count() . ' consumables purged.');
         foreach ($consumables as $consumable) {
             $this->info('- Consumable "' . $consumable->name . '" deleted.');
             $consumable->assetlog()->forceDelete();
             $consumable->forceDelete();
         }
         $components = Component::whereNotNull('deleted_at')->withTrashed()->get();
         $this->info($components->count() . ' components purged.');
         foreach ($components as $component) {
             $this->info('- Component "' . $component->name . '" deleted.');
             $component->assetlog()->forceDelete();
             $component->forceDelete();
         }
         $licenses = License::whereNotNull('deleted_at')->withTrashed()->get();
         $this->info($licenses->count() . ' licenses purged.');
         foreach ($licenses as $license) {
             $this->info('- License "' . $license->name . '" deleted.');
             $license->assetlog()->forceDelete();
             $license->licenseseats()->forceDelete();
             $license->forceDelete();
         }
         $models = AssetModel::whereNotNull('deleted_at')->withTrashed()->get();
         $this->info($models->count() . ' asset models purged.');
         foreach ($models as $model) {
             $this->info('- Asset Model "' . $model->name . '" deleted.');
             $model->forceDelete();
         }
         $categories = Category::whereNotNull('deleted_at')->withTrashed()->get();
         $this->info($categories->count() . ' categories purged.');
         foreach ($categories as $category) {
             $this->info('- Category "' . $category->name . '" deleted.');
             $category->forceDelete();
         }
         $suppliers = Supplier::whereNotNull('deleted_at')->withTrashed()->get();
         $this->info($suppliers->count() . ' suppliers purged.');
         foreach ($suppliers as $supplier) {
             $this->info('- Supplier "' . $supplier->name . '" deleted.');
             $supplier->forceDelete();
         }
         $users = User::whereNotNull('deleted_at')->where('show_in_list', '!=', '0')->withTrashed()->get();
         $this->info($users->count() . ' users purged.');
         $user_assoc = 0;
         foreach ($users as $user) {
             $this->info('- User "' . $user->username . '" deleted.');
             $user_assoc += $user->userlog()->count();
             $user->userlog()->forceDelete();
             $user->forceDelete();
         }
         $this->info($user_assoc . ' corresponding user log records purged.');
         $manufacturers = Manufacturer::whereNotNull('deleted_at')->withTrashed()->get();
         $this->info($manufacturers->count() . ' manufacturers purged.');
         foreach ($manufacturers as $manufacturer) {
             $this->info('- Manufacturer "' . $manufacturer->name . '" deleted.');
             $manufacturer->forceDelete();
         }
         $status_labels = Statuslabel::whereNotNull('deleted_at')->withTrashed()->get();
         $this->info($status_labels->count() . ' status labels purged.');
         foreach ($status_labels as $status_label) {
             $this->info('- Status Label "' . $status_label->name . '" deleted.');
             $status_label->forceDelete();
         }
     } else {
         $this->info('Action canceled. Nothing was purged.');
     }
 }
Exemple #8
0
 public function edit($id)
 {
     $components = Component::lists('name_en', 'id');
     $module = Module::findOrFail($id);
     return view('modules.edit', compact('module', 'components'));
 }
Exemple #9
0
 /**
  * This nasty little method gets the low inventory info for the
  * alert dropdown
  **/
 public static function checkLowInventory()
 {
     $consumables = Consumable::with('users')->whereNotNull('min_amt')->get();
     $accessories = Accessory::with('users')->whereNotNull('min_amt')->get();
     $components = Component::with('assets')->whereNotNull('min_amt')->get();
     $avail_consumables = 0;
     $items_array = array();
     $all_count = 0;
     foreach ($consumables as $consumable) {
         $avail = $consumable->numRemaining();
         if ($avail < $consumable->min_amt + \App\Models\Setting::getSettings()->alert_threshold) {
             if ($consumable->total_qty > 0) {
                 $percent = number_format($consumable->numRemaining() / $consumable->total_qty * 100, 0);
             } else {
                 $percent = 100;
             }
             $items_array[$all_count]['id'] = $consumable->id;
             $items_array[$all_count]['name'] = $consumable->name;
             $items_array[$all_count]['type'] = 'consumables';
             $items_array[$all_count]['percent'] = $percent;
             $items_array[$all_count]['remaining'] = $consumable->numRemaining();
             $items_array[$all_count]['min_amt'] = $consumable->min_amt;
             $all_count++;
         }
     }
     foreach ($accessories as $accessory) {
         $avail = $accessory->numRemaining();
         if ($avail < $accessory->min_amt + \App\Models\Setting::getSettings()->alert_threshold) {
             if ($accessory->total_qty > 0) {
                 $percent = number_format($accessory->numRemaining() / $accessory->total_qty * 100, 0);
             } else {
                 $percent = 100;
             }
             $items_array[$all_count]['id'] = $accessory->id;
             $items_array[$all_count]['name'] = $accessory->name;
             $items_array[$all_count]['type'] = 'accessories';
             $items_array[$all_count]['percent'] = $percent;
             $items_array[$all_count]['remaining'] = $accessory->numRemaining();
             $items_array[$all_count]['min_amt'] = $accessory->min_amt;
             $all_count++;
         }
     }
     foreach ($components as $component) {
         $avail = $component->numRemaining();
         if ($avail < $component->min_amt + \App\Models\Setting::getSettings()->alert_threshold) {
             if ($component->total_qty > 0) {
                 $percent = number_format($component->numRemaining() / $component->total_qty * 100, 0);
             } else {
                 $percent = 100;
             }
             $items_array[$all_count]['id'] = $component->id;
             $items_array[$all_count]['name'] = $component->name;
             $items_array[$all_count]['type'] = 'components';
             $items_array[$all_count]['percent'] = $percent;
             $items_array[$all_count]['remaining'] = $component->numRemaining();
             $items_array[$all_count]['min_amt'] = $component->min_amt;
             $all_count++;
         }
     }
     return $items_array;
 }
Exemple #10
0
 public function run()
 {
     Component::truncate();
     DB::table('components_assets')->truncate();
     factory(Component::class, 'component', 10)->create();
 }
 public function getAcceptAsset($logID = null)
 {
     if (!($findlog = DB::table('asset_logs')->where('id', '=', $logID)->first())) {
         echo 'no record';
         //return redirect()->to('account')->with('error', trans('admin/hardware/message.does_not_exist'));
     }
     $user = Auth::user();
     if ($user->id != $findlog->checkedout_to) {
         return redirect()->to('account/view-assets')->with('error', trans('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);
         // consumable
     } elseif ($findlog->consumable_id != '') {
         $item = Consumable::find($findlog->consumable_id);
         // components
     } elseif ($findlog->component_id != '') {
         $item = Component::find($findlog->component_id);
     }
     // Check if the asset exists
     if (is_null($item)) {
         // Redirect to the asset management page
         return redirect()->to('account')->with('error', trans('admin/hardware/message.does_not_exist'));
     } elseif (!Company::isCurrentUserHasAccess($item)) {
         return redirect()->route('requestable-assets')->with('error', trans('general.insufficient_permissions'));
     } else {
         return View::make('account/accept-asset', compact('item'))->with('findlog', $findlog);
     }
 }