Merge remote-tracking branch 'origin/develop'

This commit is contained in:
snipe 2023-03-24 06:18:10 -07:00
commit 43c286c61f
5 changed files with 35 additions and 11 deletions

View file

@ -334,7 +334,11 @@ class Helper
'#92896B',
];
$total_colors = count($colors);
if ($index >= $total_colors) {
$index = $index - $total_colors;
}
return $colors[$index];
}

View file

@ -82,8 +82,8 @@ class AssetModelsController extends Controller
$model->user_id = Auth::id();
$model->requestable = Request::has('requestable');
if ($request->input('custom_fieldset') != '') {
$model->fieldset_id = e($request->input('custom_fieldset'));
if ($request->input('fieldset_id') != '') {
$model->fieldset_id = e($request->input('fieldset_id'));
}
$model = $request->handleImages($model);
@ -160,10 +160,10 @@ class AssetModelsController extends Controller
$this->removeCustomFieldsDefaultValues($model);
if ($request->input('custom_fieldset') == '') {
if ($request->input('fieldset_id') == '') {
$model->fieldset_id = null;
} else {
$model->fieldset_id = $request->input('custom_fieldset');
$model->fieldset_id = $request->input('fieldset_id');
if ($this->shouldAddDefaultValues($request->input())) {
if (!$this->assignCustomFieldsDefaultValues($model, $request->input('default_values'))){
@ -444,7 +444,7 @@ class AssetModelsController extends Controller
{
return ! empty($input['add_default_values'])
&& ! empty($input['default_values'])
&& ! empty($input['custom_fieldset']);
&& ! empty($input['fieldset_id']);
}
/**

View file

@ -22,7 +22,7 @@ class AddIdsToTables extends Migration
Schema::table('password_resets', function (Blueprint $table) {
// Add the id column to the password_resets table if it doesn't yet have one
if (! Schema::hasColumn('password_resets', 'id')) {
if (! Schema::hasColumn('password_resets', 'id') && $this->notUsingSqlite()) {
$table->increments('id');
}
});
@ -47,4 +47,9 @@ class AddIdsToTables extends Migration
}
});
}
private function notUsingSqlite()
{
return Schema::connection($this->getConnection())->getConnection()->getDriverName() !== 'sqlite';
}
}

View file

@ -13,12 +13,27 @@ class AddsWebhookOptionToSettingsTable extends Migration
*/
public function up()
{
/**
* So...you're probably wondering why this isn't all in one Schema::table()...
* Turns out we'll get the following error:
* "SQLite doesn't support multiple calls to dropColumn / renameColumn in a single modification."
* if we're running sqlite so a solution is to make multiple calls.
* ¯\_()_/¯
*/
Schema::table('settings', function (Blueprint $table) {
$table->string('webhook_selected')->after('slack_botname')->default('slack')->nullable();
$table->renameColumn('slack_botname', 'webhook_botname');
$table->renameColumn('slack_endpoint', 'webhook_endpoint');
$table->renameColumn('slack_channel', 'webhook_channel');
$table->string('webhook_selected')->after('slack_botname')->default('slack')->nullable();
});
Schema::table('settings', function (Blueprint $table) {
$table->renameColumn('slack_botname', 'webhook_botname');
});
Schema::table('settings', function (Blueprint $table) {
$table->renameColumn('slack_endpoint', 'webhook_endpoint');
});
Schema::table('settings', function (Blueprint $table) {
$table->renameColumn('slack_channel', 'webhook_channel');
});
}

View file

@ -10,7 +10,7 @@ $expires = Helper::getFormattedDateObject($asset->present()->warranty_expires, '
$diff = round(abs(strtotime($asset->present()->warranty_expires) - strtotime(date('Y-m-d')))/86400);
$icon = ($diff <= ($threshold / 2)) ? '🚨' : (($diff <= $threshold) ? '⚠️' : ' ');
@endphp
<tr><td>{{ $icon }} </td><td> <a href="{{ route('hardware.show', $asset->id) }}">{{ $asset->present()->name }}</a> </td><td> {{ $diff }} {{ trans('mail.Days') }} </td><td> {{ $expires['formatted'] }} </td><td> {{ ($asset->supplier ? e($asset->supplier->name) : '') }} </td><td> {{ ($asset->assignedTo ? e($asset->assignedTo->present()->name()) : '') }} </td></tr>
<tr><td>{{ $icon }} </td><td> <a href="{{ route('hardware.show', $asset->id) }}">{{ $asset->present()->name }}</a> </td><td> {{ $diff }} {{ trans('mail.Days') }} </td><td> {{ !is_null($expires) ? $expires['formatted'] : '' }} </td><td> {{ ($asset->supplier ? e($asset->supplier->name) : '') }} </td><td> {{ ($asset->assignedTo ? e($asset->assignedTo->present()->name()) : '') }} </td></tr>
@endforeach
</table>
@endcomponent