Skip to content

Commit fc0278c

Browse files
committed
Merge branch 'main' of github.com:vcian/laravel-data-bringin
2 parents d28443b + eb52438 commit fc0278c

File tree

2 files changed

+171
-154
lines changed

2 files changed

+171
-154
lines changed

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
composer.lock
2-
vendor
3-
.idea
2+
/vendor
3+
/.idea

resources/views/import.blade.php

Lines changed: 169 additions & 152 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@
6565
.dropdown-toggle.show:focus {
6666
box-shadow: none !important;
6767
}
68+
.next-btn{
69+
border-left: 1px solid #ffffff;
70+
}
6871
.notes {
6972
height: 50px;
7073
background: rgb(25 135 84 / 30%);
@@ -104,177 +107,191 @@
104107
height: 50px;
105108
background: #e5e5e5;
106109
}
110+
.overflow-scroll {
111+
overflow-y: scroll !important;
112+
padding: 80px 0px;
113+
overflow-x: hidden !important;
114+
115+
}
107116
</style>
108117
</head>
109118
<body>
110119
<div class="container">
111-
<div class="py-3 d-flex align-items-center justify-content-center">
112-
<h2 class="border-bottom pb-2" ><span class="fw-bold">Laravel </span><span class="fw-light">Data Bringin</span></h2>
113-
</div>
114-
<ul class="stepper d-flex my-3">
115-
<li class="active">Upload CSV File</li>
116-
<li @class(['active' => request()->step >= 2])>Mapping</li>
117-
<li @class(['active' => request()->step >= 3])>Manage</li>
118-
<li @class(['active' => request()->step >= 4])>Result</li>
119-
</ul>
120-
<div class="progress m-auto">
121-
<div class="progress-bar bg-success progress-bar-striped progress-bar-animated"
122-
role="progressbar" style="width: {{ round((request()->step ?? 1) * 100 / 4, 2) }}%"
123-
aria-valuenow="50" aria-valuemin="0" aria-valuemax="100"></div>
124-
</div>
125-
<div class="content mx-auto my-5">
126-
@if(request()->step == 1 || !isset(request()->step))
127-
<!-- First step -->
128-
<div class="first-step">
129-
<form method="post" action="{{ route('data_bringin.store') }}" enctype="multipart/form-data">
130-
@csrf
131-
<input type="hidden" name="step" value="{{ request()->step ?? 1 }}">
132-
<div class="mt-5">
133-
<label for="formFile" class="form-label">Upload CSV File</label>
134-
<input class="form-control @error('file') is-invalid @enderror"
135-
type="file"
136-
name="file"
137-
id="file"
138-
accept=".csv" />
139-
@error('file')
140-
<div class="invalid-feedback">{{ $message }}</div>
141-
@enderror
142-
</div>
143-
<div class="btn-group mt-3" role="group" aria-label="Basic example" style="float: right;">
144-
<button type="submit" class="btn btn-success">Next</button>
145-
</div>
146-
</form>
120+
<div class="overflow-scroll">
121+
<div class="py-3 d-flex align-items-center justify-content-center">
122+
<h2 class="border-bottom pb-2" ><span class="fw-bold">Laravel </span><span class="fw-light">Data Bringin</span></h2>
147123
</div>
148-
@endif
149-
<!-- Second step -->
150-
@if(request()->step == 2)
151-
<div class="second-step">
152-
<div class="notes w-100 px-4 d-flex align-items-center
153-
position-relative">
154-
<p class="m-0"><span class="badge bg-success me-2
155-
text-uppercase">Note!</span>Please match file column name
156-
with the original table column name.
157-
</p>
124+
<ul class="stepper d-flex my-3">
125+
<li class="active">Upload CSV File</li>
126+
<li @class(['active' => request()->step >= 2])>Mapping</li>
127+
<li @class(['active' => request()->step >= 3])>Manage</li>
128+
<li @class(['active' => request()->step >= 4])>Result</li>
129+
</ul>
130+
<div class="progress m-auto">
131+
<div class="progress-bar bg-success progress-bar-striped progress-bar-animated"
132+
role="progressbar" style="width: {{ round((request()->step ?? 1) * 100 / 4, 2) }}%"
133+
aria-valuenow="50" aria-valuemin="0" aria-valuemax="100"></div>
134+
</div>
135+
<div class="content mx-auto my-5">
136+
@if(request()->step == 1 || !isset(request()->step))
137+
<!-- First step -->
138+
<div class="first-step">
139+
<form method="post" action="{{ route('data_bringin.store') }}" enctype="multipart/form-data">
140+
@csrf
141+
<input type="hidden" name="step" value="{{ request()->step ?? 1 }}">
142+
<div class="mt-5">
143+
<label for="formFile" class="form-label">Upload CSV File</label>
144+
<input class="form-control @error('file') is-invalid @enderror"
145+
type="file"
146+
name="file"
147+
id="file"
148+
accept=".csv" />
149+
@error('file')
150+
<div class="invalid-feedback">{{ $message }}</div>
151+
@enderror
152+
</div>
153+
<div class="btn-group mt-3" role="group" aria-label="Basic example" style="float: right;">
154+
<button type="submit" class="btn btn-success next-btn">Next</button>
155+
</div>
156+
</form>
158157
</div>
159-
<form method="get">
160-
<input type="hidden" name="step" value="{{ request()->step }}">
161-
<div class="mb-5 mt-5">
162-
<label for="table" class="form-label">Select Database Table</label>
163-
<select class="form-select" name="table" onchange="this.form.submit()">
164-
<option selected disabled>Select Table</option>
165-
@foreach($tables as $table)
166-
<option @selected($table == $selectedTable)>
167-
{{ $table }}
168-
</option>
169-
@endforeach
170-
</select>
171-
</div>
172-
</form>
173-
@if($selectedTable)
174-
<form method="post" action="{{ route('data_bringin.store') }}">
175-
@csrf
176-
<input type="hidden" name="step" value="{{ request()->step }}">
177-
<input type="hidden" name="table" value="{{ $selectedTable }}">
178-
<table class="table table-responsive table-bordered my-3">
179-
<tbody>
180-
@foreach($tableColumns as $column)
181-
<tr>
182-
<td class="w-50 align-middle text-uppercase">{{ $column }}</td>
183-
<td class="w-50">
184-
<select class="form-select" name="columns[{{$column}}]">
185-
<option selected disabled>Select Column</option>
186-
@foreach($fileColumns as $val)
187-
<option @selected(isset($selectedColumns[$column]) && $selectedColumns[$column] == $val)>{{ $val }}</option>
188-
@endforeach
189-
</select>
190-
</td>
191-
</tr>
192-
@endforeach
193-
</tbody>
194-
</table>
195-
<div class="btn-group mt-3" role="group" style="float: right;">
196-
<a href="{{ route('data_bringin.index', ['step' => --request()->step]) }}" class="btn btn-success">Prev</a>
197-
<button type="submit" class="btn btn-success">Next</button>
198-
</div>
199-
</form>
200158
@endif
201-
</div>
202-
@endif
203-
<!-- Third step -->
204-
@if(request()->step == 3)
205-
<div class="third-step">
206-
<div class="table-responsive table-height">
207-
<table class="table table-bordered my-3">
208-
<thead>
209-
<tr class="text-uppercase">
210-
<th></th>
211-
<th>id</th>
212-
@foreach($tableColumns as $column)
213-
<th>{{ $column }}</th>
214-
@endforeach
215-
</tr>
216-
</thead>
217-
<tbody>
218-
@foreach($fileData as $key => $data)
219-
<tr>
220-
<td class="text-center">
221-
<a href="{{ route('data_bringin.delete_record', $data['Id']) }}" onclick="return confirm('Are you sure you want to delete this record?')" class="bg-transparent border-0 p-0">
222-
<i class="fa fa-trash text-danger"></i>
223-
</a>
224-
</td>
225-
<td>{{ ++$key }}</td>
159+
<!-- Second step -->
160+
@if(request()->step == 2)
161+
<div class="second-step">
162+
<div class="notes w-100 px-4 d-flex align-items-center
163+
position-relative">
164+
<p class="m-0"><span class="badge bg-success me-2
165+
text-uppercase">Note!</span>Please match file column name
166+
with the original table column name.
167+
</p>
168+
</div>
169+
<form method="get">
170+
<input type="hidden" name="step" value="{{ request()->step }}">
171+
<div class="mb-5 mt-5">
172+
<label for="table" class="form-label">Select Database Table</label>
173+
<select class="form-select" name="table" onchange="this.form.submit()">
174+
<option selected disabled>Select Table</option>
175+
@foreach($tables as $table)
176+
<option @selected($table == $selectedTable)>
177+
{{ $table }}
178+
</option>
179+
@endforeach
180+
</select>
181+
</div>
182+
</form>
183+
@if($selectedTable)
184+
<form method="post" action="{{ route('data_bringin.store') }}">
185+
@csrf
186+
<input type="hidden" name="step" value="{{ request()->step }}">
187+
<input type="hidden" name="table" value="{{ $selectedTable }}">
188+
<table class="table table-responsive table-bordered my-3">
189+
<thead>
190+
<tr>
191+
<th>Database Table Column</th>
192+
<th>CSV File Column</th>
193+
</tr>
194+
</thead>
195+
<tbody>
226196
@foreach($tableColumns as $column)
227-
<td>{{ (isset($selectedColumns[$column]) && isset($data[$selectedColumns[$column]])) ? $data[$selectedColumns[$column]] : '' }}</td>
197+
<tr>
198+
<td class="w-50 align-middle text-uppercase">{{ $column }}</td>
199+
<td class="w-50">
200+
<select class="form-select" name="columns[{{$column}}]">
201+
<option selected disabled>Select Column</option>
202+
@foreach($fileColumns as $val)
203+
<option @selected(isset($selectedColumns[$column]) && $selectedColumns[$column] == $val)>{{ $val }}</option>
204+
@endforeach
205+
</select>
206+
</td>
207+
</tr>
228208
@endforeach
229-
</tr>
230-
@endforeach
231-
</tbody>
232-
</table>
209+
</tbody>
210+
</table>
211+
<div class="btn-group mt-3" role="group" style="float: right;">
212+
<a href="{{ route('data_bringin.index', ['step' => --request()->step]) }}" class="btn btn-success">Prev</a>
213+
<button type="submit" class="btn btn-success next-btn">Next</button>
214+
</div>
215+
</form>
216+
@endif
233217
</div>
234-
<form method="post" action="{{ route('data_bringin.store') }}">
235-
@csrf
236-
<input type="hidden" name="step" value="{{ request()->step }}">
237-
<div class="btn-group mt-3" role="group" style="float: right;">
238-
<a href="{{ route('data_bringin.index', ['step' => --request()->step]) }}" class="btn btn-success">Prev</a>
239-
<button type="submit" class="btn btn-success">Save</button>
218+
@endif
219+
<!-- Third step -->
220+
@if(request()->step == 3)
221+
<div class="third-step">
222+
<div class="table-responsive table-height">
223+
<table class="table table-bordered my-3">
224+
<thead>
225+
<tr class="text-uppercase">
226+
<th></th>
227+
<th>id</th>
228+
@foreach($tableColumns as $column)
229+
<th>{{ $column }}</th>
230+
@endforeach
231+
</tr>
232+
</thead>
233+
<tbody>
234+
@foreach($fileData as $key => $data)
235+
<tr>
236+
<td class="text-center">
237+
<a href="{{ route('data_bringin.delete_record', $data['Id']) }}" onclick="return confirm('Are you sure you want to delete this record?')" class="bg-transparent border-0 p-0">
238+
<i class="fa fa-trash text-danger"></i>
239+
</a>
240+
</td>
241+
<td>{{ ++$key }}</td>
242+
@foreach($tableColumns as $column)
243+
<td>{{ (isset($selectedColumns[$column]) && isset($data[$selectedColumns[$column]])) ? $data[$selectedColumns[$column]] : '' }}</td>
244+
@endforeach
245+
</tr>
246+
@endforeach
247+
</tbody>
248+
</table>
240249
</div>
241-
</form>
242-
</div>
243-
@endif
244-
<!-- Fourth step -->
245-
@if(request()->step == 4)
246-
<div class="fourth-step">
247-
@if($result && !$result['error'])
248-
<div class="notes w-100 px-4 d-flex align-items-center
249-
position-relative">
250-
<div class="d-flex align-items-center">
251-
<div class="svg-wrapper">
252-
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6">
253-
<path stroke-linecap="round" stroke-linejoin="round" d="M9 12.75L11.25 15 15 9.75M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
254-
</svg>
250+
<form method="post" action="{{ route('data_bringin.store') }}">
251+
@csrf
252+
<input type="hidden" name="step" value="{{ request()->step }}">
253+
<div class="btn-group mt-3" role="group" style="float: right;">
254+
<a href="{{ route('data_bringin.index', ['step' => --request()->step]) }}" class="btn btn-success">Prev</a>
255+
<button type="submit" class="btn btn-success next-btn">Save</button>
255256
</div>
256-
<p class="dark-green mx-2 mb-0 mt-">{{ $result['count'] }} Data Imported <span class="fw-bold">Successfully</span>.</p>
257-
</div>
257+
</form>
258258
</div>
259259
@endif
260-
@if($result && $result['error'])
261-
<div class="notes-error w-100 px-4 d-flex align-items-center
262-
position-relative">
263-
<div class="d-flex align-items-center">
264-
<div class="svg-wrapper">
265-
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6">
266-
<path stroke-linecap="round" stroke-linejoin="round" d="M12 9v3.75m9-.75a9 9 0 11-18 0 9 9 0 0118 0zm-9 3.75h.008v.008H12v-.008z" />
267-
</svg>
260+
<!-- Fourth step -->
261+
@if(request()->step == 4)
262+
<div class="fourth-step">
263+
@if($result && !$result['error'])
264+
<div class="notes w-100 px-4 d-flex align-items-center
265+
position-relative">
266+
<div class="d-flex align-items-center">
267+
<div class="svg-wrapper">
268+
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6">
269+
<path stroke-linecap="round" stroke-linejoin="round" d="M9 12.75L11.25 15 15 9.75M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
270+
</svg>
271+
</div>
272+
<p class="dark-green mx-2 mb-0 mt-">{{ $result['count'] }} Data Imported <span class="fw-bold">Successfully</span>.</p>
273+
</div>
274+
</div>
275+
@endif
276+
@if($result && $result['error'])
277+
<div class="notes-error w-100 px-4 d-flex align-items-center
278+
position-relative">
279+
<div class="d-flex align-items-center">
280+
<div class="svg-wrapper">
281+
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6">
282+
<path stroke-linecap="round" stroke-linejoin="round" d="M12 9v3.75m9-.75a9 9 0 11-18 0 9 9 0 0118 0zm-9 3.75h.008v.008H12v-.008z" />
283+
</svg>
284+
</div>
285+
<p class="text-danger mx-2 mb-0 mt-">{{ $result['error'] }}</p>
268286
</div>
269-
<p class="text-danger mx-2 mb-0 mt-">{{ $result['error'] }}</p>
287+
</div>
288+
@endif
289+
<div class="btn-group mt-3" role="group" aria-label="Basic example" style="float: right;">
290+
<a href="{{ route('data_bringin.index') }}" class="btn btn-success">Continue</a>
270291
</div>
271292
</div>
272293
@endif
273-
<div class="btn-group mt-3" role="group" aria-label="Basic example" style="float: right;">
274-
<a href="{{ route('data_bringin.index') }}" class="btn btn-success">Continue</a>
275-
</div>
276294
</div>
277-
@endif
278295
</div>
279296
</div>
280297
<footer class="d-flex align-items-center justify-content-between w-100 position-fixed bottom-0 left-0 px-3">

0 commit comments

Comments
 (0)