|
| 1 | +@extends('layouts.app') |
| 2 | + |
| 3 | +@section('content') |
| 4 | + <div class="container"> |
| 5 | + <div class="row justify-content-center"> |
| 6 | + <div class="col-md-10"> |
| 7 | + <div class="card"> |
| 8 | + <div class="card-header">{{ __('Bulk Import SquidUsers (CSV)') }}</div> |
| 9 | + |
| 10 | + <div class="card-body"> |
| 11 | + @if(session('message')) |
| 12 | + <div class="alert alert-info"> |
| 13 | + <h5>{{ __('Import Results') }}</h5> |
| 14 | + <pre>{{ session('message') }}</pre> |
| 15 | + </div> |
| 16 | + @endif |
| 17 | + |
| 18 | + @if($errors->any()) |
| 19 | + <div class="alert alert-danger"> |
| 20 | + <ul class="mb-0"> |
| 21 | + @foreach($errors->all() as $error) |
| 22 | + <li>{{ $error }}</li> |
| 23 | + @endforeach |
| 24 | + </ul> |
| 25 | + </div> |
| 26 | + @endif |
| 27 | + |
| 28 | + <form method="POST" action="{{ route('squiduser.bulk.import') }}" enctype="multipart/form-data"> |
| 29 | + @csrf |
| 30 | + |
| 31 | + <div class="mb-4"> |
| 32 | + <h5>{{ __('CSV Format Instructions') }}</h5> |
| 33 | + <div class="alert alert-secondary"> |
| 34 | + <p class="mb-2"><strong>{{ __('CSV Header (First Row):') }}</strong></p> |
| 35 | + <code>user,password,enabled,fullname,comment</code> |
| 36 | + |
| 37 | + <p class="mt-3 mb-2"><strong>{{ __('Example for CREATE:') }}</strong></p> |
| 38 | + <pre class="mb-0">user,password,enabled,fullname,comment |
| 39 | +testuser1,password123,1,Test User One,First test user |
| 40 | +testuser2,password456,1,Test User Two,Second test user</pre> |
| 41 | + |
| 42 | + <p class="mt-3 mb-2"><strong>{{ __('Example for UPDATE:') }}</strong></p> |
| 43 | + <pre class="mb-0">user,password,enabled,fullname,comment |
| 44 | +testuser1,newpassword,0,Updated Name,Updated comment</pre> |
| 45 | + <small class="text-muted">{{ __('Note: For UPDATE, the "user" field is used to find existing records. Empty fields will not be updated.') }}</small> |
| 46 | + |
| 47 | + <p class="mt-3 mb-2"><strong>{{ __('Example for DELETE:') }}</strong></p> |
| 48 | + <pre class="mb-0">user,password,enabled,fullname,comment |
| 49 | +testuser1,,,,</pre> |
| 50 | + <small class="text-muted">{{ __('Note: For DELETE, only the "user" field is required.') }}</small> |
| 51 | + </div> |
| 52 | + </div> |
| 53 | + |
| 54 | + <div class="mb-3"> |
| 55 | + <label for="operation" class="form-label">{{ __('Operation Type') }}</label> |
| 56 | + <select name="operation" id="operation" class="form-select" required> |
| 57 | + <option value="">{{ __('Select Operation') }}</option> |
| 58 | + <option value="create">{{ __('Create (Add new users)') }}</option> |
| 59 | + <option value="update">{{ __('Update (Modify existing users)') }}</option> |
| 60 | + <option value="delete">{{ __('Delete (Remove users)') }}</option> |
| 61 | + </select> |
| 62 | + </div> |
| 63 | + |
| 64 | + <div class="mb-3"> |
| 65 | + <label for="csv_file" class="form-label">{{ __('CSV File') }}</label> |
| 66 | + <input type="file" name="csv_file" id="csv_file" class="form-control" accept=".csv,.txt" required> |
| 67 | + <small class="form-text text-muted"> |
| 68 | + {{ __('Maximum file size: 10MB. Supported formats: .csv, .txt') }} |
| 69 | + </small> |
| 70 | + </div> |
| 71 | + |
| 72 | + <div class="d-flex justify-content-between align-items-center"> |
| 73 | + <a href="{{ route('squiduser.search', auth()->user()->id) }}" class="btn btn-secondary"> |
| 74 | + {{ __('Back to List') }} |
| 75 | + </a> |
| 76 | + <button type="submit" class="btn btn-primary"> |
| 77 | + {{ __('Upload and Process') }} |
| 78 | + </button> |
| 79 | + </div> |
| 80 | + </form> |
| 81 | + |
| 82 | + <hr class="my-4"> |
| 83 | + |
| 84 | + <div class="alert alert-warning"> |
| 85 | + <h6 class="alert-heading">{{ __('Important Notes:') }}</h6> |
| 86 | + <ul class="mb-0"> |
| 87 | + <li>{{ __('The CSV file must use comma (,) as delimiter') }}</li> |
| 88 | + <li>{{ __('The first row must contain column headers') }}</li> |
| 89 | + <li>{{ __('For CREATE operation, all fields are required except fullname and comment') }}</li> |
| 90 | + <li>{{ __('For UPDATE operation, existing users are matched by the "user" field') }}</li> |
| 91 | + <li>{{ __('For DELETE operation, only the "user" field is needed') }}</li> |
| 92 | + <li>{{ __('All operations are executed in a transaction - if one fails, all will be rolled back') }}</li> |
| 93 | + </ul> |
| 94 | + </div> |
| 95 | + </div> |
| 96 | + </div> |
| 97 | + </div> |
| 98 | + </div> |
| 99 | + </div> |
| 100 | +@endsection |
0 commit comments