Merge remote-tracking branch 'origin/v3' into v3-master

This commit is contained in:
snipe 2016-06-22 12:30:48 -07:00
commit 5daaa24a07
37 changed files with 1975 additions and 1958 deletions

View file

@ -1,5 +1,6 @@
<?php
namespace App\Console\Commands;
use App\Models\User;
use App\Models\Location;
use App\Models\Category;
@ -13,7 +14,8 @@ use Symfony\Component\Console\Input\InputArgument;
use Illuminate\Console\Command;
use League\Csv\Reader;
class AssetImportCommand extends Command {
class AssetImportCommand extends Command
{
/**
* The console command name.
@ -72,91 +74,91 @@ class AssetImportCommand extends Command {
// Let's just map some of these entries to more user friendly words
// User's name
if (array_key_exists('0',$row)) {
if (array_key_exists('0', $row)) {
$user_name = trim($row[0]);
} else {
$user_name = '';
}
// User's email
if (array_key_exists('1',$row)) {
if (array_key_exists('1', $row)) {
$user_email = trim($row[1]);
} else {
$user_email = '';
}
// User's email
if (array_key_exists('2',$row)) {
if (array_key_exists('2', $row)) {
$user_username = trim($row[2]);
} else {
$user_username = '';
}
// Asset Name
if (array_key_exists('3',$row)) {
if (array_key_exists('3', $row)) {
$user_asset_asset_name = trim($row[3]);
} else {
$user_asset_asset_name = '';
}
// Asset Category
if (array_key_exists('4',$row)) {
if (array_key_exists('4', $row)) {
$user_asset_category = trim($row[4]);
} else {
$user_asset_category = '';
}
// Asset Name
if (array_key_exists('5',$row)) {
if (array_key_exists('5', $row)) {
$user_asset_name = trim($row[5]);
} else {
$user_asset_name = '';
}
// Asset Manufacturer
if (array_key_exists('6',$row)) {
if (array_key_exists('6', $row)) {
$user_asset_mfgr = trim($row[6]);
} else {
$user_asset_mfgr = '';
}
// Asset model number
if (array_key_exists('7',$row)) {
if (array_key_exists('7', $row)) {
$user_asset_modelno = trim($row[7]);
} else {
$user_asset_modelno = '';
}
// Asset serial number
if (array_key_exists('8',$row)) {
if (array_key_exists('8', $row)) {
$user_asset_serial = trim($row[8]);
} else {
$user_asset_serial = '';
}
// Asset tag
if (array_key_exists('9',$row)) {
if (array_key_exists('9', $row)) {
$user_asset_tag = trim($row[9]);
} else {
$user_asset_tag = '';
}
// Asset location
if (array_key_exists('10',$row)) {
if (array_key_exists('10', $row)) {
$user_asset_location = trim($row[10]);
} else {
$user_asset_location = '';
}
// Asset notes
if (array_key_exists('11',$row)) {
if (array_key_exists('11', $row)) {
$user_asset_notes = trim($row[11]);
} else {
$user_asset_notes = '';
}
// Asset purchase date
if (array_key_exists('12',$row)) {
if (array_key_exists('12', $row)) {
if ($row[12]!='') {
$user_asset_purchase_date = date("Y-m-d 00:00:01", strtotime($row[12]));
} else {
@ -167,7 +169,7 @@ class AssetImportCommand extends Command {
}
// Asset purchase cost
if (array_key_exists('13',$row)) {
if (array_key_exists('13', $row)) {
if ($row[13]!='') {
$user_asset_purchase_cost = trim($row[13]);
} else {
@ -178,7 +180,7 @@ class AssetImportCommand extends Command {
}
// Asset Company Name
if (array_key_exists('14',$row)) {
if (array_key_exists('14', $row)) {
if ($row[14]!='') {
$user_asset_company_name = trim($row[14]);
} else {
@ -277,8 +279,7 @@ class AssetImportCommand extends Command {
$location = new Location();
if ($user_asset_location!='')
{
if ($user_asset_location!='') {
$location->name = e($user_asset_location);
$location->address = '';
$location->city = '';
@ -295,14 +296,10 @@ class AssetImportCommand extends Command {
$this->error($location->getErrors());
}
}
else
{
} else {
$this->comment('Location '.$user_asset_location.' was (not) created - test run only');
}
}
else
{
} else {
$this->comment('No location given, so none created.');
}
@ -463,6 +460,4 @@ class AssetImportCommand extends Command {
array('testrun', null, InputOption::VALUE_REQUIRED, 'Test the output without writing to the database or not.', null),
);
}
}

View file

@ -5,7 +5,6 @@ namespace App\Console\Commands;
use Illuminate\Console\Command;
use App\Models\Setting;
class DisableLDAP extends Command
{
/**

View file

@ -10,7 +10,8 @@ use App\Models\Supplier;
use App\Models\License;
use App\Models\LicenseSeat;
class LicenseImportCommand extends Command {
class LicenseImportCommand extends Command
{
/**
* The console command name.
@ -68,55 +69,55 @@ class LicenseImportCommand extends Command {
// Let's just map some of these entries to more user friendly words
if (array_key_exists('0',$row)) {
if (array_key_exists('0', $row)) {
$user_name = trim($row[0]);
} else {
$user_name = '';
}
if (array_key_exists('1',$row)) {
if (array_key_exists('1', $row)) {
$user_email = trim($row[1]);
} else {
$user_email = '';
}
if (array_key_exists('2',$row)) {
if (array_key_exists('2', $row)) {
$user_username = trim($row[2]);
} else {
$user_username = '';
}
if (array_key_exists('3',$row)) {
if (array_key_exists('3', $row)) {
$user_license_name = trim($row[3]);
} else {
$user_license_name = '';
}
if (array_key_exists('4',$row)) {
if (array_key_exists('4', $row)) {
$user_license_serial = trim($row[4]);
} else {
$user_license_serial = '';
}
if (array_key_exists('5',$row)) {
if (array_key_exists('5', $row)) {
$user_licensed_to_name = trim($row[5]);
} else {
$user_licensed_to_name = '';
}
if (array_key_exists('6',$row)) {
if (array_key_exists('6', $row)) {
$user_licensed_to_email = trim($row[6]);
} else {
$user_licensed_to_email = '';
}
if (array_key_exists('7',$row)) {
if (array_key_exists('7', $row)) {
$user_license_seats = trim($row[7]);
} else {
$user_license_seats = '';
}
if (array_key_exists('8',$row)) {
if (array_key_exists('8', $row)) {
$user_license_reassignable = trim($row[8]);
if ($user_license_reassignable!='') {
if ((strtolower($user_license_reassignable)=='yes') || (strtolower($user_license_reassignable)=='true') || ($user_license_reassignable=='1')) {
@ -129,13 +130,13 @@ class LicenseImportCommand extends Command {
$user_license_reassignable = 0;
}
if (array_key_exists('9',$row)) {
if (array_key_exists('9', $row)) {
$user_license_supplier = trim($row[9]);
} else {
$user_license_supplier = '';
}
if (array_key_exists('10',$row)) {
if (array_key_exists('10', $row)) {
$user_license_maintained = trim($row[10]);
if ($user_license_maintained!='') {
@ -151,13 +152,13 @@ class LicenseImportCommand extends Command {
$user_license_maintained = '';
}
if (array_key_exists('11',$row)) {
if (array_key_exists('11', $row)) {
$user_license_notes = trim($row[11]);
} else {
$user_license_notes = '';
}
if (array_key_exists('12',$row)) {
if (array_key_exists('12', $row)) {
if ($row[12]!='') {
$user_license_purchase_date = date("Y-m-d 00:00:01", strtotime($row[12]));
} else {
@ -191,18 +192,18 @@ class LicenseImportCommand extends Command {
$email_last_name = $last_name;
$email_prefix = $first_name;
} else {
$last_name = str_replace($first_name,'',$user_name);
$last_name = str_replace($first_name, '', $user_name);
if ($this->option('email_format')=='filastname') {
$email_last_name.=str_replace(' ','',$last_name);
$email_last_name.=str_replace(' ', '', $last_name);
$email_prefix = $first_name[0].$email_last_name;
} elseif ($this->option('email_format')=='firstname.lastname') {
$email_last_name.=str_replace(' ','',$last_name);
$email_last_name.=str_replace(' ', '', $last_name);
$email_prefix = $first_name.'.'.$email_last_name;
} elseif ($this->option('email_format')=='firstname') {
$email_last_name.=str_replace(' ','',$last_name);
$email_last_name.=str_replace(' ', '', $last_name);
$email_prefix = $first_name;
}
@ -218,7 +219,7 @@ class LicenseImportCommand extends Command {
$status_id = 7;
}
$email = strtolower($email_prefix).'@'.$this->option('domain');
$user_email = str_replace("'",'',$email);
$user_email = str_replace("'", '', $email);
}
}
@ -379,6 +380,4 @@ class LicenseImportCommand extends Command {
array('testrun', null, InputOption::VALUE_REQUIRED, 'Test the output without writing to the database or not.', null),
);
}
}

View file

@ -27,7 +27,8 @@ ini_set('memory_limit', '500M');
/**
* Class ObjectImportCommand
*/
class ObjectImportCommand extends Command {
class ObjectImportCommand extends Command
{
/**
* The console command name.
@ -63,7 +64,7 @@ class ObjectImportCommand extends Command {
$filename = $this->argument('filename');
if(!$this->option('web-importer')) {
if (!$this->option('web-importer')) {
$logFile = $this->option('logfile');
\Log::useFiles($logFile);
if ($this->option('testrun')) {
@ -84,8 +85,7 @@ class ObjectImportCommand extends Command {
$results = $csv->fetchAssoc();
$newarray = null;
foreach ($results as $index => $arraytoNormalize)
{
foreach ($results as $index => $arraytoNormalize) {
$internalnewarray = array_change_key_case($arraytoNormalize);
$newarray[$index] = $internalnewarray;
}
@ -104,17 +104,17 @@ class ObjectImportCommand extends Command {
$this->consumables = Consumable::All(['name']);
$this->customfields = CustomField::All(['name']);
$bar = null;
if(!$this->option('web-importer')) {
if (!$this->option('web-importer')) {
$bar = $this->output->createProgressBar(count($newarray));
}
// Loop through the records
DB::transaction(function() use (&$newarray, $bar){
DB::transaction(function () use (&$newarray, $bar) {
Model::unguard();
$item_type = strtolower($this->option('item-type'));
foreach( $newarray as $row ) {
foreach ($newarray as $row) {
// Let's just map some of these entries to more user friendly words
@ -139,10 +139,13 @@ class ObjectImportCommand extends Command {
$item["notes"] = $this->array_smart_fetch($row, "notes");
$item["quantity"] = $this->array_smart_fetch($row, "quantity");
$item["requestable"] = $this->array_smart_fetch($row, "requestable");
$item["asset_tag"] = $this->array_smart_fetch($row, "asset tag");
$this->current_assetId = $item["item_name"];
if ($item["asset_tag"] != '') {
$this->current_assetId = $item["asset_tag"];
}
$this->log('Category: ' . $item_category);
$this->log('Location: ' . $item_location);
$this->log('Purchase Date: ' . $item["purchase_date"]);
@ -182,34 +185,32 @@ class ObjectImportCommand extends Command {
break;
}
if(!$this->option('web-importer')) {
if (!$this->option('web-importer')) {
$bar->advance();
}
$this->log('------------- Action Summary ----------------');
}
});
if(!$this->option('web-importer')) {
if (!$this->option('web-importer')) {
$bar->finish();
}
$this->log('=====================================');
if(!$this->option('web-importer'))
{
if(!empty($this->errors)) {
if (!$this->option('web-importer')) {
if (!empty($this->errors)) {
$this->comment("The following Errors were encountered.");
foreach($this->errors as $asset => $error)
{
foreach ($this->errors as $asset => $error) {
$this->comment('Error: Item: ' . $asset . 'failed validation: ' . json_encode($error));
}
} else {
$this->comment("All Items imported successfully!");
}
} else {
if(empty($this->errors))
if (empty($this->errors)) {
return 0;
else {
} else {
$this->comment(json_encode($this->errors)); //Send a big string to the
return 1;
}
@ -226,9 +227,10 @@ class ObjectImportCommand extends Command {
public function jsonError($field, $errorString)
{
$this->errors[$this->current_assetId] = array($field => $errorString);
if($this->option('verbose'))
parent::error($errorString);
$this->errors[$this->current_assetId][$field] = $errorString;
if ($this->option('verbose')) {
parent::error($field . $errorString);
}
}
/**
@ -242,16 +244,15 @@ class ObjectImportCommand extends Command {
*/
private function log($string, $level = 'info')
{
if($this->option('web-importer'))
if ($this->option('web-importer')) {
return;
if($level === 'warning')
{
}
if ($level === 'warning') {
\Log::warning($string);
$this->comment($string);
}
else {
} else {
\Log::Info($string);
if($this->option('verbose')) {
if ($this->option('verbose')) {
$this->comment($string);
}
}
@ -267,8 +268,9 @@ class ObjectImportCommand extends Command {
* @param $default string
* @return string
*/
public function array_smart_fetch(Array $array, $key, $default = '') {
return array_key_exists($key,$array) ? e(trim($array[ $key ])) : $default;
public function array_smart_fetch(array $array, $key, $default = '')
{
return array_key_exists($key, $array) ? e(trim($array[ $key ])) : $default;
}
@ -280,9 +282,10 @@ class ObjectImportCommand extends Command {
* @param $array array
* @return string
*/
public function array_smart_custom_field_fetch(Array $array, $key) {
public function array_smart_custom_field_fetch(array $array, $key)
{
$index_name = strtolower($key->name);
return array_key_exists($index_name,$array) ? e(trim($array[$index_name])) : '';
return array_key_exists($index_name, $array) ? e(trim($array[$index_name])) : '';
}
@ -304,10 +307,12 @@ class ObjectImportCommand extends Command {
$asset_model_name = $this->array_smart_fetch($row, "model name");
$asset_modelno = $this->array_smart_fetch($row, "model number");
if(empty($asset_model_name))
if (empty($asset_model_name)) {
$asset_model_name='Unknown';
if(empty($asset_modelno))
}
if (empty($asset_modelno)) {
$asset_modelno='';
}
$this->log('Model Name: ' . $asset_model_name);
$this->log('Model No: ' . $asset_modelno);
@ -316,8 +321,7 @@ class ObjectImportCommand extends Command {
if ((strcasecmp($tempmodel->name, $asset_model_name) == 0)
&& $tempmodel->modelno == $asset_modelno
&& $tempmodel->category_id == $category->id
&& $tempmodel->manufacturer_id == $manufacturer->id )
{
&& $tempmodel->manufacturer_id == $manufacturer->id ) {
$this->log('A matching model ' . $asset_model_name . ' with model number ' . $asset_modelno . ' already exists');
return $tempmodel;
}
@ -330,7 +334,7 @@ class ObjectImportCommand extends Command {
$asset_model->user_id = $this->option('user_id');
if(!$this->option('testrun')) {
if (!$this->option('testrun')) {
if ($asset_model->save()) {
$this->asset_models->add($asset_model);
$this->log('Asset Model ' . $asset_model_name . ' with model number ' . $asset_modelno . ' was created');
@ -359,11 +363,12 @@ class ObjectImportCommand extends Command {
*/
public function createOrFetchCategory($asset_category, $item_type)
{
if (empty($asset_category))
if (empty($asset_category)) {
$asset_category = 'Unnamed Category';
}
foreach($this->categories as $tempcategory) {
if( (strcasecmp($tempcategory->name, $asset_category) == 0) && $tempcategory->category_type === $item_type) {
foreach ($this->categories as $tempcategory) {
if ((strcasecmp($tempcategory->name, $asset_category) == 0) && $tempcategory->category_type === $item_type) {
$this->log('Category ' . $asset_category . ' already exists');
return $tempcategory;
}
@ -376,7 +381,7 @@ class ObjectImportCommand extends Command {
$category->user_id = $this->option('user_id');
if(!$this->option('testrun')) {
if (!$this->option('testrun')) {
if ($category->save()) {
$this->categories->add($category);
$this->log('Category ' . $asset_category . ' was created');
@ -414,7 +419,7 @@ class ObjectImportCommand extends Command {
$company = new Company();
$company->name = $asset_company_name;
if(!$this->option('testrun')) {
if (!$this->option('testrun')) {
if ($company->save()) {
$this->companies->add($company);
$this->log('Company ' . $asset_company_name . ' was created');
@ -438,10 +443,11 @@ class ObjectImportCommand extends Command {
*/
public function createOrFetchStatusLabel($asset_statuslabel_name)
{
if(empty($asset_statuslabel_name))
if (empty($asset_statuslabel_name)) {
return;
}
foreach ($this->status_labels as $tempstatus) {
if (strcasecmp($tempstatus->name, $asset_statuslabel_name) == 0 ) {
if (strcasecmp($tempstatus->name, $asset_statuslabel_name) == 0) {
$this->log('A matching Status ' . $asset_statuslabel_name . ' already exists');
return $tempstatus;
}
@ -450,7 +456,7 @@ class ObjectImportCommand extends Command {
$status->name = $asset_statuslabel_name;
if(!$this->option('testrun')) {
if (!$this->option('testrun')) {
if ($status->save()) {
$this->status_labels->add($status);
$this->log('Status ' . $asset_statuslabel_name . ' was created');
@ -481,13 +487,13 @@ class ObjectImportCommand extends Command {
{
$asset_mfgr = $this->array_smart_fetch($row, "manufacturer");
if(empty($asset_mfgr)) {
if (empty($asset_mfgr)) {
$asset_mfgr='Unknown';
}
$this->log('Manufacturer ID: ' . $asset_mfgr);
foreach ($this->manufacturers as $tempmanufacturer) {
if (strcasecmp($tempmanufacturer->name, $asset_mfgr) == 0 ) {
if (strcasecmp($tempmanufacturer->name, $asset_mfgr) == 0) {
$this->log('Manufacturer ' . $asset_mfgr . ' already exists') ;
return $tempmanufacturer;
}
@ -529,8 +535,8 @@ class ObjectImportCommand extends Command {
*/
public function createOrFetchLocation($asset_location)
{
foreach($this->locations as $templocation) {
if( strcasecmp($templocation->name, $asset_location) == 0 ) {
foreach ($this->locations as $templocation) {
if (strcasecmp($templocation->name, $asset_location) == 0) {
$this->log('Location ' . $asset_location . ' already exists');
return $templocation;
}
@ -579,8 +585,9 @@ class ObjectImportCommand extends Command {
public function createOrFetchSupplier(array $row)
{
$supplier_name = $this->array_smart_fetch($row, "supplier");
if(empty($supplier_name))
if (empty($supplier_name)) {
$supplier_name='Unknown';
}
foreach ($this->suppliers as $tempsupplier) {
if (strcasecmp($tempsupplier->name, $supplier_name) == 0) {
$this->log('A matching Company ' . $supplier_name . ' already exists');
@ -592,7 +599,7 @@ class ObjectImportCommand extends Command {
$supplier->name = $supplier_name;
$supplier->user_id = $this->option('user_id');
if(!$this->option('testrun')) {
if (!$this->option('testrun')) {
if ($supplier->save()) {
$this->suppliers->add($supplier);
$this->log('Supplier ' . $supplier_name . ' was created');
@ -666,15 +673,16 @@ class ObjectImportCommand extends Command {
$this->log('Email: ' . $user_email);
$this->log('--- End User Data ---');
if($this->option('testrun'))
if ($this->option('testrun')) {
return new User;
}
if (!empty($user_username)) {
if ($user = User::MatchEmailOrUsername($user_username, $user_email)
->whereNotNull('username')->first()) {
$this->log('User '.$user_username.' already exists');
} else if(( $first_name != '') && ($last_name != '') && ($user_username != '')) {
} elseif (( $first_name != '') && ($last_name != '') && ($user_username != '')) {
$user = new \App\Models\User;
$password = substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 20);
@ -709,35 +717,31 @@ class ObjectImportCommand extends Command {
* @param array $row
* @param array $item
*/
public function createAssetIfNotExists(array $row, array $item )
public function createAssetIfNotExists(array $row, array $item)
{
$asset_serial = $this->array_smart_fetch($row, "serial number");
$asset_tag = $this->array_smart_fetch($row, "asset tag");
$asset_image = $this->array_smart_fetch($row, "image");
$asset_warranty_months = intval($this->array_smart_fetch($row, "warranty months"));
if(empty($asset_warranty_months)) {
if (empty($asset_warranty_months)) {
$asset_warranty_months = null;
}
// Check for the asset model match and create it if it doesn't exist
$asset_model = $this->createOrFetchAssetModel($row, $item["category"], $item["manufacturer"]);
$supplier = $this->createOrFetchSupplier($row);
$this->current_assetId = $asset_tag;
$this->log('Serial No: '.$asset_serial);
$this->log('Asset Tag: '.$asset_tag);
$this->log('Asset Tag: '.$item['asset_tag']);
$this->log('Notes: '.$item["notes"]);
$this->log('Warranty Months: ' . $asset_warranty_months);
foreach ($this->assets as $tempasset) {
if (strcasecmp($tempasset->asset_tag, $asset_tag ) == 0 ) {
$this->log('A matching Asset ' . $asset_tag . ' already exists');
// $this->comment('A matching Asset ' . $asset_tag . ' already exists');
if (strcasecmp($tempasset->asset_tag, $item['asset_tag']) == 0) {
$this->log('A matching Asset ' . $item['asset_tag'] . ' already exists');
return;
}
}
if($item["status_label"]) {
if ($item["status_label"]) {
$status_id = $item["status_label"]->id;
} else {
@ -754,7 +758,7 @@ class ObjectImportCommand extends Command {
$asset->purchase_date = null;
}
if( array_key_exists('custom_fields', $item)) {
if (array_key_exists('custom_fields', $item)) {
foreach ($item['custom_fields'] as $custom_field => $val) {
$asset->{$custom_field} = $val;
}
@ -762,30 +766,35 @@ class ObjectImportCommand extends Command {
if (!empty($item["purchase_cost"])) {
//TODO How to generalize this for not USD?
$purchase_cost = substr($item["purchase_cost"],0,1) === '$' ? substr($item["purchase_cost"],1) : $item["purchase_cost"];
$asset->purchase_cost = number_format($purchase_cost,2);
$purchase_cost = substr($item["purchase_cost"], 0, 1) === '$' ? substr($item["purchase_cost"], 1) : $item["purchase_cost"];
$asset->purchase_cost = number_format($purchase_cost, 2);
$this->log("Asset cost parsed: " . $asset->purchase_cost);
} else {
$asset->purchase_cost = 0.00;
}
$asset->serial = $asset_serial;
$asset->asset_tag = $asset_tag;
$asset->asset_tag = $item['asset_tag'];
$asset->warranty_months = $asset_warranty_months;
if($asset_model)
if ($asset_model) {
$asset->model_id = $asset_model->id;
if($item["user"])
}
if ($item["user"]) {
$asset->assigned_to = $item["user"]->id;
if($item["location"])
}
if ($item["location"]) {
$asset->rtd_location_id = $item["location"]->id;
}
$asset->user_id = $this->option('user_id');
$this->log("status_id: " . $status_id);
$asset->status_id = $status_id;
if($item["company"])
if ($item["company"]) {
$asset->company_id = $item["company"]->id;
}
$asset->order_number = $item["order_number"];
if($supplier)
if ($supplier) {
$asset->supplier_id = $supplier->id;
}
$asset->notes = $item["notes"];
$asset->image = $asset_image;
$this->assets->add($asset);
@ -811,11 +820,11 @@ class ObjectImportCommand extends Command {
* @since 3.0
* @param $item array
*/
public function createAccessoryIfNotExists(array $item )
public function createAccessoryIfNotExists(array $item)
{
$this->log("Creating Accessory");
foreach ($this->accessories as $tempaccessory) {
if (strcasecmp($tempaccessory->name, $item["item_name"] ) == 0 ) {
if (strcasecmp($tempaccessory->name, $item["item_name"]) == 0) {
$this->log('A matching Accessory ' . $item["item_name"] . ' already exists. ');
// FUTURE: Adjust quantity on import maybe?
return;
@ -831,25 +840,28 @@ class ObjectImportCommand extends Command {
$accessory->purchase_date = null;
}
if (!empty($item["purchase_cost"])) {
$accessory->purchase_cost = number_format(e($item["purchase_cost"]),2);
$accessory->purchase_cost = number_format(e($item["purchase_cost"]), 2);
} else {
$accessory->purchase_cost = 0.00;
}
if($item["location"])
if ($item["location"]) {
$accessory->location_id = $item["location"]->id;
}
$accessory->user_id = $this->option('user_id');
if($item["company"])
if ($item["company"]) {
$accessory->company_id = $item["company"]->id;
}
$accessory->order_number = $item["order_number"];
if($item["category"])
if ($item["category"]) {
$accessory->category_id = $item["category"]->id;
}
//TODO: Implement
// $accessory->notes = e($item_notes);
$accessory->requestable = filter_var($item["requestable"], FILTER_VALIDATE_BOOLEAN);
//Must have at least zero of the item if we import it.
if($item["quantity"] > -1) {
if ($item["quantity"] > -1) {
$accessory->qty = $item["quantity"];
} else {
$accessory->qty = 1;
@ -880,8 +892,8 @@ class ObjectImportCommand extends Command {
public function createConsumableIfNotExists(array $item)
{
$this->log("Creating Consumable");
foreach($this->consumables as $tempconsumable) {
if(strcasecmp($tempconsumable->name, $item["item_name"]) == 0) {
foreach ($this->consumables as $tempconsumable) {
if (strcasecmp($tempconsumable->name, $item["item_name"]) == 0) {
$this->log("A matching consumable " . $item["item_name"] . " already exists");
//TODO: Adjust quantity if different maybe?
return;
@ -891,14 +903,14 @@ class ObjectImportCommand extends Command {
$consumable = new Consumable();
$consumable->name = $item["item_name"];
if(!empty($item["purchase_date"])) {
if (!empty($item["purchase_date"])) {
$consumable->purchase_date = $item["purchase_date"];
} else {
$consumable->purchase_date = null;
}
if(!empty($item["purchase_cost"])) {
$consumable->purchase_cost = number_format(e($item["purchase_cost"]),2);
if (!empty($item["purchase_cost"])) {
$consumable->purchase_cost = number_format(e($item["purchase_cost"]), 2);
} else {
$consumable->purchase_cost = 0.00;
}
@ -911,14 +923,14 @@ class ObjectImportCommand extends Command {
//$consumable->notes= e($item_notes);
$consumable->requestable = filter_var($item["requestable"], FILTER_VALIDATE_BOOLEAN);
if($item["quantity"] > -1) {
if ($item["quantity"] > -1) {
$consumable->qty = $item["quantity"];
} else {
$consumable->qty = 1;
}
if(!$this->option("testrun")) {
if($consumable->save()) {
if (!$this->option("testrun")) {
if ($consumable->save()) {
$this->log("Consumable " . $item["item_name"] . ' was created');
// $this->comment("Consumable " . $item["item_name"] . ' was created');
@ -965,7 +977,4 @@ class ObjectImportCommand extends Command {
);
}
}

View file

@ -29,7 +29,7 @@ class PaveIt extends Command
* @var string
*/
protected $signature = 'snipeit:pave
{--soft: Perform a "Soft" Delete, leaving all migrations, table structure, and the first user in place.}';
{--soft : Perform a "Soft" Delete, leaving all migrations, table structure, and the first user in place.}';
/**
* The console command description.
@ -55,10 +55,8 @@ class PaveIt extends Command
*/
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'))
{
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();

View file

@ -140,7 +140,7 @@ class Purge extends Command
$supplier->forceDelete();
}
$users = User::whereNotNull('deleted_at')->where('show_in_list','!=','0')->withTrashed()->get();
$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) {

View file

@ -1,6 +1,7 @@
<?php
namespace App\Console\Commands;
use App\Models\Asset;
use App\Models\License;
use App\Models\Setting;
@ -8,7 +9,8 @@ use DB;
use Illuminate\Console\Command;
class SendExpirationAlerts extends Command {
class SendExpirationAlerts extends Command
{
/**
* The console command name.
@ -99,7 +101,7 @@ class SendExpirationAlerts extends Command {
if (count($expiring_assets) > 0) {
\Mail::send('emails.expiring-assets-report', $asset_data, function ($m) {
$m->to(explode(',',Setting::getSettings()->alert_email), Setting::getSettings()->site_name);
$m->to(explode(',', Setting::getSettings()->alert_email), Setting::getSettings()->site_name);
$m->subject('Expiring Assets Report');
});
@ -107,7 +109,7 @@ class SendExpirationAlerts extends Command {
if (count($expiring_licenses) > 0) {
\Mail::send('emails.expiring-licenses-report', $license_data, function ($m) {
$m->to(explode(',',Setting::getSettings()->alert_email), Setting::getSettings()->site_name);
$m->to(explode(',', Setting::getSettings()->alert_email), Setting::getSettings()->site_name);
$m->subject('Expiring Licenses Report');
});
@ -128,9 +130,4 @@ class SendExpirationAlerts extends Command {
}
}

View file

@ -49,7 +49,7 @@ class SendInventoryAlerts extends Command
if (count($data['data']) > 0) {
\Mail::send('emails.low-inventory', $data, function ($m) {
$m->to(explode(',',Setting::getSettings()->alert_email), Setting::getSettings()->site_name);
$m->to(explode(',', Setting::getSettings()->alert_email), Setting::getSettings()->site_name);
$m->subject('Low Inventory Report');
});
@ -65,5 +65,4 @@ class SendInventoryAlerts extends Command
}
}

View file

@ -4,7 +4,8 @@ namespace App\Console\Commands;
use Illuminate\Console\Command;
class SystemBackup extends Command {
class SystemBackup extends Command
{
/**
* The console command name.
@ -41,7 +42,4 @@ class SystemBackup extends Command {
$this->call('backup:run');
}
}

View file

@ -6,7 +6,8 @@ use Symfony\Component\Console\Input\InputArgument;
use Illuminate\Console\Command;
class Versioning extends Command {
class Versioning extends Command
{
/**
* The console command name.

View file

@ -322,6 +322,7 @@ class AccessoriesController extends Controller
$admin_user = Auth::user();
$settings = Setting::getSettings();
if ($settings->slack_endpoint) {

View file

@ -80,16 +80,17 @@ class AssetsController extends Controller
* @since [v3.0]
* @return Redirect
*/
public function getAssetByTag() {
public function getAssetByTag()
{
if (Input::get('topsearch')=="true") {
$topsearch = true;
} else {
$topsearch = false;
}
if ($asset = Asset::where('asset_tag','=',Input::get('assetTag'))->first()) {
if ($asset = Asset::where('asset_tag', '=', Input::get('assetTag'))->first()) {
return redirect()->route('view/hardware', $asset->id)->with('topsearch', $topsearch);
}
return redirect()->to('hardware')->with('error',trans('admin/hardware/message.does_not_exist'));
return redirect()->to('hardware')->with('error', trans('admin/hardware/message.does_not_exist'));
}
@ -211,8 +212,8 @@ class AssetsController extends Controller
if (Input::has('image')) {
$image = Input::get('image');
$header = explode(';', $image, 2)[0];
$extension = substr( $header, strpos($header, '/')+1);
$image = substr( $image, strpos($image, ',')+1);
$extension = substr($header, strpos($header, '/')+1);
$image = substr($image, strpos($image, ',')+1);
$file_name = str_random(25).".".$extension;
$path = public_path('uploads/assets/'.$file_name);
@ -231,9 +232,8 @@ class AssetsController extends Controller
// FIXME: No idea why this is returning a Builder error on db_column_name.
// Need to investigate and fix. Using static method for now.
$model = AssetModel::find($request->get('model_id'));
if($model->fieldset)
{
foreach($model->fieldset->fields as $field) {
if ($model->fieldset) {
foreach ($model->fieldset->fields as $field) {
$asset->{\App\Models\CustomField::name_to_db_name($field->name)} = e($request->input(\App\Models\CustomField::name_to_db_name($field->name)));
}
}
@ -254,8 +254,9 @@ class AssetsController extends Controller
\Session::flash('success', trans('admin/hardware/message.create.success'));
return response()->json(['redirect_url' => route('hardware')]);
}
return response()->json(['errors' => $asset->getErrors()]);
\Input::flash();
\Session::flash('errors', $asset->getErrors());
return response()->json(['errors' => $asset->getErrors()], 500);
}
/**
@ -383,8 +384,8 @@ class AssetsController extends Controller
if (Input::has('image')) {
$image = $request->input('image');
$header = explode(';', $image, 2)[0];
$extension = substr( $header, strpos($header, '/')+1);
$image = substr( $image, strpos($image, ',')+1);
$extension = substr($header, strpos($header, '/')+1);
$image = substr($image, strpos($image, ',')+1);
$file_name = str_random(25).".".$extension;
$path = public_path('uploads/assets/'.$file_name);
@ -401,13 +402,12 @@ class AssetsController extends Controller
// FIXME: No idea why this is returning a Builder error on db_column_name.
// Need to investigate and fix. Using static method for now.
$model = AssetModel::find($request->get('model_id'));
if($model->fieldset)
{
foreach($model->fieldset->fields as $field) {
if ($model->fieldset) {
foreach ($model->fieldset->fields as $field) {
$asset->{\App\Models\CustomField::name_to_db_name($field->name)} = e($request->input(\App\Models\CustomField::name_to_db_name($field->name)));
// LOG::debug($field->name);
// LOG::debug(\App\Models\CustomField::name_to_db_name($field->name));
// LOG::debug($field->db_column_name());
// LOG::debug($field->name);
// LOG::debug(\App\Models\CustomField::name_to_db_name($field->name));
// LOG::debug($field->db_column_name());
}
}
@ -417,8 +417,9 @@ class AssetsController extends Controller
\Session::flash('success', trans('admin/hardware/message.update.success'));
return response()->json(['redirect_url' => route("view/hardware", $assetId)]);
}
return response()->json(['errors' => $asset->getErrors()]);
\Input::flash();
\Session::flash('errors', $asset->getErrors());
return response()->json(['errors' => $asset->getErrors()], 500);
}
@ -611,7 +612,7 @@ class AssetsController extends Controller
'fields' => [
[
'title' => 'Checked In:',
'value' => strtoupper($logaction->asset_type).' asset <'.config('app.url').'/hardware/'.$asset->id.'/view'.'|'.e($asset->showAssetName()).'> checked in by <'.config('app.url').'/hardware/'.$asset->id.'/view'.'|'.e(Auth::user()->fullName()).'>.'
'value' => strtoupper($logaction->asset_type).' asset <'.config('app.url').'/hardware/'.$asset->id.'/view'.'|'.e($asset->showAssetName()).'> checked in by <'.config('app.url').'/admin/users/'.Auth::user()->id.'/view'.'|'.e(Auth::user()->fullName()).'>.'
],
[
'title' => 'Note:',
@ -776,8 +777,9 @@ class AssetsController extends Controller
}
// Check if the uploads directory exists. If not, try to create it.
if(!file_exists($path))
if (!file_exists($path)) {
mkdir($path, 0755);
}
if ($handle = opendir($path)) {
/* This is the correct way to loop over the directory. */
@ -874,19 +876,21 @@ class AssetsController extends Controller
return redirect()->to('hardware')->with('error', trans('general.insufficient_permissions'));
}
$return = Artisan::call('snipeit:import',
$return = Artisan::call(
'snipeit:import',
['filename'=> config('app.private_uploads').'/imports/assets/'.$filename,
'--email_format'=>'firstname.lastname',
'--username_format'=>'firstname.lastname',
'--web-importer' => true,
'--user_id' => Auth::user()->id
]);
]
);
$display_output = Artisan::output();
$file = config('app.private_uploads').'/imports/assets/'.str_replace('.csv', '', $filename).'-output-'.date("Y-m-d-his").'.txt';
file_put_contents($file, $display_output);
if( $return === 0) //Success
if ($return === 0) { //Success
return redirect()->to('hardware')->with('success', trans('admin/hardware/message.import.success'));
else if( $return === 1) { // Failure
} elseif ($return === 1) { // Failure
return redirect()->back()->with('import_errors', json_decode($display_output))->with('error', trans('admin/hardware/message.import.error'));
}
dd("Shouldn't be here");
@ -962,7 +966,7 @@ class AssetsController extends Controller
} elseif (isset($asset->id)) {
// Restore the asset
Asset::withTrashed()->where('id',$assetId)->restore();
Asset::withTrashed()->where('id', $assetId)->restore();
return redirect()->route('hardware')->with('success', trans('admin/hardware/message.restore.success'));
} else {

View file

@ -244,7 +244,7 @@ class CategoriesController extends Controller
public function getDatatable()
{
// Grab all the categories
$categories = Category::with('assets', 'accessories', 'consumables','components');
$categories = Category::with('assets', 'accessories', 'consumables', 'components');
if (Input::has('search')) {
$categories = $categories->TextSearch(e(Input::get('search')));
@ -300,7 +300,8 @@ class CategoriesController extends Controller
return $data;
}
public function getDataViewAssets($categoryID) {
public function getDataViewAssets($categoryID)
{
$category = Category::with('assets.company')->find($categoryID);
$category_assets = $category->assets();
@ -369,7 +370,8 @@ class CategoriesController extends Controller
public function getDataViewAccessories($categoryID) {
public function getDataViewAccessories($categoryID)
{
$category = Category::with('accessories.company')->find($categoryID);
$category_assets = $category->accessories;
@ -422,7 +424,8 @@ class CategoriesController extends Controller
}
public function getDataViewConsumables($categoryID) {
public function getDataViewConsumables($categoryID)
{
$category = Category::with('accessories.company')->find($categoryID);
$category_assets = $category->consumables;
@ -474,7 +477,8 @@ class CategoriesController extends Controller
return $data;
}
public function getDataViewComponent($categoryID) {
public function getDataViewComponent($categoryID)
{
$category = Category::with('accessories.company')->find($categoryID);
$category_assets = $category->components;
@ -525,7 +529,4 @@ class CategoriesController extends Controller
$data = array('total' => $count, 'rows' => $rows);
return $data;
}
}

View file

@ -260,7 +260,8 @@ class CustomFieldsController extends Controller
* @since [v3.0]
* @return Array
*/
public function postReorder($id) {
public function postReorder($id)
{
$fieldset=CustomFieldset::find($id);
$fields = array();

View file

@ -11,7 +11,6 @@ use Str;
use View;
use Auth;
/**
* This controller handles all actions related to Depreciations for
* the Snipe-IT Asset Management application.

View file

@ -93,7 +93,7 @@ class GroupsController extends Controller
$permissions = config('permissions');
$groupPermissions = $group->decodePermissions();
$selected_array = Helper::selectedPermissionsArray($permissions, $groupPermissions);
return View::make('groups/edit', compact('group', 'permissions','selected_array','groupPermissions'));
return View::make('groups/edit', compact('group', 'permissions', 'selected_array', 'groupPermissions'));
}
/**

View file

@ -156,7 +156,7 @@ class LicensesController extends Controller
$insertedId = $license->id;
// Save the license seat data
DB::transaction(function() use (&$insertedId,&$license) {
DB::transaction(function () use (&$insertedId, &$license) {
for ($x=0; $x<$license->seats; $x++) {
$license_seat = new LicenseSeat();
$license_seat->license_id = $insertedId;

View file

@ -370,7 +370,7 @@ class LocationsController extends Controller
public function getDataViewUsers($locationID)
{
$location = Location::find($locationID);
$users = User::where('location_id','=',$location->id);
$users = User::where('location_id', '=', $location->id);
if (Input::has('search')) {
$users = $users->TextSearch(e(Input::get('search')));

View file

@ -110,7 +110,7 @@ class ReportsController extends Controller
->orderBy('created_at', 'DESC')
->get();
return View::make('reports/asset', compact('assets'))->with('settings',$settings);
return View::make('reports/asset', compact('assets'))->with('settings', $settings);
}
/**

View file

@ -49,7 +49,7 @@ class SettingsController extends Controller
$start_settings['db_error'] = $e->getMessage();
}
$protocol = array_key_exists('HTTPS',$_SERVER) && ( $_SERVER['HTTPS'] == "on") ? 'https://' : 'http://';
$protocol = array_key_exists('HTTPS', $_SERVER) && ( $_SERVER['HTTPS'] == "on") ? 'https://' : 'http://';
$pageURL = $protocol;
@ -97,7 +97,7 @@ class SettingsController extends Controller
}
if(function_exists('posix_getpwuid')) { // Probably Linux
if (function_exists('posix_getpwuid')) { // Probably Linux
$owner = posix_getpwuid(fileowner($_SERVER["SCRIPT_FILENAME"]));
$start_settings['owner'] = $owner['name'];
} else { // Windows
@ -552,7 +552,7 @@ class SettingsController extends Controller
{
if (!config('app.lock_passwords')) {
if (Input::get('confirm_purge')=='DELETE') {
Artisan::call('snipeit:purge',['--force'=>'true','--no-interaction'=>true]);
Artisan::call('snipeit:purge', ['--force'=>'true','--no-interaction'=>true]);
$output = Artisan::output();
return View::make('settings/purge')
->with('output', $output)->with('success', trans('admin/settings/message.purge.success'));

View file

@ -33,7 +33,6 @@ use URL;
use View;
use Illuminate\Http\Request;
/**
* This controller handles all actions related to Users for
* the Snipe-IT Asset Management application.
@ -431,7 +430,7 @@ class UsersController extends Controller
//print_r($licenses);
$users = User::whereIn('id', $user_raw_array)->with('groups', 'assets', 'licenses','accessories')->get();
$users = User::whereIn('id', $user_raw_array)->with('groups', 'assets', 'licenses', 'accessories')->get();
// $users = Company::scopeCompanyables($users)->get();
return View::make('users/confirm-bulk-delete', compact('users', 'statuslabel_list'));
@ -523,7 +522,7 @@ class UsersController extends Controller
$logaction->logaction('checkin from');
}
LicenseSeat::whereIn('id', $license_array)->update(['assigned_to' => NULL]);
LicenseSeat::whereIn('id', $license_array)->update(['assigned_to' => null]);
foreach ($users as $user) {
$user->accessories()->sync(array());
@ -562,10 +561,10 @@ class UsersController extends Controller
} else {
// Restore the user
if (User::withTrashed()->where('id',$id)->restore()) {
if (User::withTrashed()->where('id', $id)->restore()) {
return redirect()->route('users')->with('success', trans('admin/users/message.success.restored'));
} else {
return redirect()->route('users')->with('error','User could not be restored.');
return redirect()->route('users')->with('error', 'User could not be restored.');
}
}
@ -698,8 +697,8 @@ class UsersController extends Controller
->with('company_list', $company_list)
->with('manager_list', $manager_list)
->with('user', $user)
->with('groups',$groups)
->with('userGroups',$userGroups)
->with('groups', $groups)
->with('userGroups', $userGroups)
->with('clone_user', $user_to_clone);
} catch (UserNotFoundException $e) {
// Prepare the error message

View file

@ -59,7 +59,7 @@ class ViewAssetsController extends Controller
public function getRequestableIndex()
{
$assets = Asset::with('model', 'defaultLoc', 'assetloc','assigneduser')->Hardware()->RequestableAssets()->get();
$assets = Asset::with('model', 'defaultLoc', 'assetloc', 'assigneduser')->Hardware()->RequestableAssets()->get();
return View::make('account/requestable-assets', compact('user', 'assets'));
}
@ -143,7 +143,7 @@ class ViewAssetsController extends Controller
public function getAcceptAsset($logID = null)
{
if (!$findlog = DB::table('asset_logs')->where('id','=',$logID)->first()) {
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'));
}
@ -189,7 +189,7 @@ class ViewAssetsController extends Controller
{
// Check if the asset exists
if (is_null($findlog = DB::table('asset_logs')->where('id','=',$logID)->first())) {
if (is_null($findlog = DB::table('asset_logs')->where('id', '=', $logID)->first())) {
// Redirect to the asset management page
return redirect()->to('account/view-assets')->with('error', trans('admin/hardware/message.does_not_exist'));
}

View file

@ -24,7 +24,7 @@ class CheckForSetup
} else {
if (!$request->is('setup*')) {
return redirect(config('app.url').'/setup')->with('Request',$request);
return redirect(config('app.url').'/setup')->with('Request', $request);
}
return $next($request);

View file

@ -7,7 +7,6 @@ use Config;
use Route;
use Gate;
class CheckPermissions
{
/**

View file

@ -5,6 +5,7 @@ namespace App\Http\Requests;
use App\Http\Requests\Request;
use App\Models\AssetModel;
use Session;
class AssetRequest extends Request
{
/**
@ -40,8 +41,7 @@ class AssetRequest extends Request
$model = AssetModel::find($this->request->get('model_id'));
if (($model) && ($model->fieldset))
{
if (($model) && ($model->fieldset)) {
$rules += $model->fieldset->validation_rules();
}

View file

@ -138,14 +138,22 @@ Route::group([ 'prefix' => 'api', 'middleware' => 'auth' ], function () {
Route::group([ 'prefix' => 'categories' ], function () {
Route::get('list', [ 'as' => 'api.categories.list', 'uses' => 'CategoriesController@getDatatable' ]);
Route::get( '{categoryID}/asset/view',
[ 'as' => 'api.categories.asset.view', 'uses' => 'CategoriesController@getDataViewAssets' ] );
Route::get( '{categoryID}/accessory/view',
[ 'as' => 'api.categories.accessory.view', 'uses' => 'CategoriesController@getDataViewAccessories' ] );
Route::get( '{categoryID}/consumable/view',
[ 'as' => 'api.categories.consumable.view', 'uses' => 'CategoriesController@getDataViewConsumables' ] );
Route::get( '{categoryID}/component/view',
[ 'as' => 'api.categories.component.view', 'uses' => 'CategoriesController@getDataViewComponent' ] );
Route::get(
'{categoryID}/asset/view',
[ 'as' => 'api.categories.asset.view', 'uses' => 'CategoriesController@getDataViewAssets' ]
);
Route::get(
'{categoryID}/accessory/view',
[ 'as' => 'api.categories.accessory.view', 'uses' => 'CategoriesController@getDataViewAccessories' ]
);
Route::get(
'{categoryID}/consumable/view',
[ 'as' => 'api.categories.consumable.view', 'uses' => 'CategoriesController@getDataViewConsumables' ]
);
Route::get(
'{categoryID}/component/view',
[ 'as' => 'api.categories.component.view', 'uses' => 'CategoriesController@getDataViewComponent' ]
);
});
/*-- Suppliers API (mostly for creating new ones in-line while creating an asset) --*/

View file

@ -172,8 +172,9 @@ class Asset extends Depreciable
}
public function getDetailedNameAttribute() {
if($this->assigned_user) {
public function getDetailedNameAttribute()
{
if ($this->assigned_user) {
$user_name = $user->fullName();
} else {
$user_name = "Unassigned";
@ -542,13 +543,13 @@ class Asset extends Depreciable
public function scopeAssetsByLocation($query, $location)
{
return $query->where(function ($query) use ($location)
{
$query->whereHas('assigneduser', function ($query) use ($location)
{
return $query->where(function ($query) use ($location) {
$query->whereHas('assigneduser', function ($query) use ($location) {
$query->where('users.location_id', '=', $location->id);
})->orWhere(function ($query) use ($location)
{
})->orWhere(function ($query) use ($location) {
$query->where('assets.rtd_location_id', '=', $location->id);
$query->whereNull('assets.assigned_to');
});

View file

@ -37,7 +37,4 @@ class Group extends Model
{
return json_decode($this->permissions, true);
}
}

View file

@ -55,7 +55,8 @@ class Setting extends Model
return $static_cache;
}
public static function setupCompleted() {
public static function setupCompleted()
{
$users_table_exists = Schema::hasTable('users');
$settings_table_exists = Schema::hasTable('settings');

View file

@ -56,7 +56,7 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
$user_permissions = json_decode($this->permissions, true);
//If the user is explicitly granted, return false
if (($user_permissions!='') && ((array_key_exists($section, $user_permissions)) && ($user_permissions[$section]=='1')) ) {
if (($user_permissions!='') && ((array_key_exists($section, $user_permissions)) && ($user_permissions[$section]=='1'))) {
return true;
}
@ -76,7 +76,8 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
return false;
}
public function isSuperUser() {
public function isSuperUser()
{
if (!$user_permissions = json_decode($this->permissions, true)) {
return false;
}

View file

@ -79,16 +79,18 @@
<th>Errors</th>
</thead>
<tbody>
@foreach (session('import_errors') as $asset => $error)
@foreach (session('import_errors') as $asset => $itemErrors)
<tr>
<td> {{ $asset }}</td>
@foreach ($error as $field => $values )
<td> <span><b>{{ $field }}:</b>
<td>
@foreach ($itemErrors as $field => $values )
<b>{{ $field }}:</b>
@foreach( $values as $errorString)
<span>{{$errorString[0]}} </span>
@endforeach
</td>
<br />
@endforeach
</td>
</tr>
@endforeach
</tbody>

View file

@ -249,10 +249,14 @@
<td>{{ trans('admin/hardware/form.notes') }}</td>
<td>{{ $asset->notes }}</td>
</tr>
@if ($asset->created_at)
<tr>
<td>{{ trans('general.created_at') }}</td>
<td>{{ $asset->created_at->format('F j, Y h:iA') }}</td>
<td>
{{ $user->created_at->format('F j, Y h:iA') }}
</td>
</tr>
@endif
</tbody>
</table>
</div> <!-- /table-responsive -->

View file

@ -111,10 +111,14 @@
<td>{{ $user->userloc->name }}</td>
</tr>
@endif
@if ($user->created_at)
<tr>
<td>{{ trans('general.created_at') }}</td>
<td>{{ $user->created_at->format('F j, Y h:iA') }}</td>
<td>
{{ $user->created_at->format('F j, Y h:iA') }}
</td>
</tr>
@endif
</table>
</div>