コード例 #1
0
 public function testDepreciationAdd()
 {
     $depreciations = factory(Depreciation::class, 'depreciation')->make();
     $values = ['name' => $depreciations->name, 'months' => $depreciations->months];
     Depreciation::create($values);
     $this->tester->seeRecord('depreciations', $values);
 }
コード例 #2
0
ファイル: PaveIt.php プロジェクト: dmeltzer/snipe-it
 /**
  * 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');
         }
     }
 }
コード例 #3
0
 public function postDeleteAll($id)
 {
     $depreciations = \App\Models\Depreciation::where('report_id', $id)->delete();
     return redirect()->back();
 }
コード例 #4
0
 /**
  * Returns a form with existing license data to allow an admin to
  * update license information.
  *
  * @author [A. Gianotto] [<*****@*****.**>]
  * @since [v1.0]
  * @param int $licenseId
  * @return View
  */
 public function getEdit($licenseId = null)
 {
     // Check if the license exists
     if (is_null($license = License::find($licenseId))) {
         // Redirect to the blogs management page
         return redirect()->to('admin/licenses')->with('error', trans('admin/licenses/message.does_not_exist'));
     } elseif (!Company::isCurrentUserHasAccess($license)) {
         return redirect()->to('admin/licenses')->with('error', trans('general.insufficient_permissions'));
     }
     if ($license->purchase_date == "0000-00-00") {
         $license->purchase_date = null;
     }
     if ($license->purchase_cost == "0.00") {
         $license->purchase_cost = null;
     }
     // Show the page
     $license_options = array('' => 'Top Level') + DB::table('assets')->where('id', '!=', $licenseId)->pluck('name', 'id');
     $depreciation_list = array('0' => trans('admin/licenses/form.no_depreciation')) + Depreciation::pluck('name', 'id')->toArray();
     $supplier_list = array('' => 'Select Supplier') + Supplier::orderBy('name', 'asc')->pluck('name', 'id')->toArray();
     $maintained_list = array('' => 'Maintained', '1' => 'Yes', '0' => 'No');
     $company_list = Helper::companyList();
     return View::make('licenses/edit', compact('license'))->with('license_options', $license_options)->with('depreciation_list', $depreciation_list)->with('supplier_list', $supplier_list)->with('company_list', $company_list)->with('maintained_list', $maintained_list);
 }
コード例 #5
0
 public function run()
 {
     Depreciation::truncate();
     factory(Depreciation::class, 'depreciation')->create();
 }
コード例 #6
0
ファイル: Helper.php プロジェクト: stijni/snipe-it
 public static function depreciationList()
 {
     $depreciation_list = ['' => 'Do Not Depreciate'] + Depreciation::orderBy('name', 'asc')->pluck('name', 'id')->toArray();
     return $depreciation_list;
 }
コード例 #7
0
 /**
  * Generates the JSON used to display the depreciation listing.
  *
  * @see DepreciationsController::getIndex()
  * @author [A. Gianotto] [<*****@*****.**>]
  * @param  string  $status
  * @since [v1.2]
  * @return String JSON
  */
 public function getDatatable()
 {
     $depreciations = Depreciation::select(array('id', 'name', 'months'));
     if (Input::has('search')) {
         $depreciations = $depreciations->TextSearch(e(Input::get('search')));
     }
     if (Input::has('offset')) {
         $offset = e(Input::get('offset'));
     } else {
         $offset = 0;
     }
     if (Input::has('limit')) {
         $limit = e(Input::get('limit'));
     } else {
         $limit = 50;
     }
     $allowed_columns = ['id', 'name', 'months'];
     $order = Input::get('order') === 'asc' ? 'asc' : 'desc';
     $sort = in_array(Input::get('sort'), $allowed_columns) ? Input::get('sort') : 'created_at';
     $depreciations->orderBy($sort, $order);
     $depreciationsCount = $depreciations->count();
     $depreciations = $depreciations->skip($offset)->take($limit)->get();
     $rows = array();
     foreach ($depreciations as $depreciation) {
         $actions = '<a href="' . route('update/depreciations', $depreciation->id) . '" class="btn btn-warning btn-sm" style="margin-right:5px;"><i class="fa fa-pencil icon-white"></i></a><a data-html="false" class="btn delete-asset btn-danger btn-sm" data-toggle="modal" href="' . route('delete/depreciations', $depreciation->id) . '" data-content="' . trans('admin/depreciations/message.delete.confirm') . '" data-title="' . trans('general.delete') . ' ' . htmlspecialchars($depreciation->name) . '?" onClick="return false;"><i class="fa fa-trash icon-white"></i></a>';
         $rows[] = array('id' => $depreciation->id, 'name' => e($depreciation->name), 'months' => e($depreciation->months), 'actions' => $actions);
     }
     $data = array('total' => $depreciationsCount, 'rows' => $rows);
     return $data;
 }