# Salary
resources / views / Salary /
# Index.Blade
resources / views / Salary / index.blade.php
@extends('layouts.master')
@section('page-title') Salary @endsection
@section('content')
<div class="mb-2">
<nav aria-label="breadcrumb" class="bg-white p-2 shadow-sm rounded">
<ol class="breadcrumb mb-0">
<li class="breadcrumb-item active" aria-current="page">Salary /</li>
</ol>
</nav>
</div>
<div class="card border-0 shadow-sm rounded">
<div class="card-body">
<div class="d-flex justify-content-between align-items-center">
<h4 class="fw-bold text-black-50 mb-0">
<i class="fa-solid fa-layer-group me-1"></i>Salary Lists
</h4>
@can('Create Salary')
<a href="{{ route('salary.create') }}" class="btn btn-outline-primary">
<i class="fa-solid fa-square-plus"></i>
</a>
@endcan
</div>
<hr>
<table class="table table-hover w-100" id="employee-table">
<thead class="bg-primary text-white">
<tr>
<th class="no-sort no-search">Control</th>
<th >Employee Name</th>
<th >Month</th>
<th >Year</th>
<th >Amount (MMK)</th>
<th class="no-sort no-search">Action</th>
<th>Date</th>
</tr>
</thead>
</table>
</div>
</div>
@endsection
@section('js')
<script>
$(document).ready(function (){
let table = $('#employee-table').DataTable({
ajax: '{{ route('salary.dataTable') }}',
columns: [
{ data: 'plus_icon', name: 'plus_icon' },
{ data: 'employee_name', name: 'employee_name' },
{ data: 'month', name: 'month' },
{ data: 'year', name: 'year' },
{ data: 'amount', name: 'amount' },
{ data: 'action', name: 'action' },
{ data: 'created_at', name: 'created_at' },
],
order: [[ 5, "asc"]],
columnDefs: [
{
"targets": [ 0 ],
"class": "control"
},
{
"targets": [6], // hidden can use
"visible": false
},
{
"targets": 'no-sort',
"orderable": false
},
{
"targets": 'no-search',
"searchable": false
},
{
"targets": 'hidden',
"visible": false
}
],
});
$(document).on('click','.delete-btn', function (e){
e.preventDefault();
let id = $(this).data('id');
let name = $(this).data('name');
Swal.fire({
title: 'Are you sure?',
text: "You won't be able to revert this!",
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#f15858',
confirmButtonText: 'Delete'
}).then((result) => {
if (result.isConfirmed) {
$.ajax({
method: "DELETE",
url: `/salary/${id}`,
}).done(function (res){
Swal.fire(
'Deleted!',
"<span class='fw-bold text-black'>"+ name +"</span>" + " has been deleted.",
'success'
);
table.ajax.reload();
});
}
})
});
$(document).on('click','.delete-btn', function (e){
e.preventDefault();
let id = $(this).data('id');
let name = $(this).data('name');
Swal.fire({
title: 'Are you sure?',
text: "You won't be able to revert this!",
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#f15858',
confirmButtonText: 'Delete'
}).then((result) => {
if (result.isConfirmed) {
$.ajax({
method: "DELETE",
url: `/salary/${id}`,
}).done(function (res){
Swal.fire(
'Deleted!',
"<span class='fw-bold text-black'>"+ name +"</span>" + " has been deleted.",
'success'
);
table.ajax.reload();
});
}
})
});
});
</script>
@endsection
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# Create.Blade
resources / views / Salary / create.blade.php
@extends('layouts.master')
@section('page-title') Salary @endsection
@section('content')
<div class="mb-2">
<nav aria-label="breadcrumb" class="bg-white p-2 shadow-sm rounded">
<ol class="breadcrumb mb-0">
<li class="breadcrumb-item">
<a href="{{ route('salary.index') }}" class="text-decoration-none">Salary</a>
</li>
<li class="breadcrumb-item active" aria-current="page">Create New Salary</li>
</ol>
</nav>
</div>
<div class="card border-0 shadow-sm rounded">
<div class="card-body">
<div class="d-flex justify-content-between align-items-center">
<h4 class="fw-bold text-black-50 mb-0">
<i class="fa-solid fa-square-plus me-1"></i>Create New Salary
</h4>
<a href="{{ route('salary.index') }}" class="btn btn-outline-primary">
<i class="fa-solid fa-list"></i>
</a>
</div>
<hr>
<form action="{{ route('salary.store') }}"
method="post" id="create-department"
class="row justify-content-center py-2">
@csrf
<div class="col-12 col-md-8">
<div class="mb-3">
<select class="form-select form-select-lg select-2"
data-placeholder="Choose Employee's Name"
name="user">
<option></option>
@forelse($employees as $e)
<option value="{{ $e->id }}"
@if( old('user') == $e->id) selected @endif>
{{ $e->name }} ( {{ $e->employee_id }} )
</option>
@empty
@endforelse
</select>
</div>
<div class="mb-3">
@php
$monthArr = ["January", "February", "March",
"April", "May", "June",
"July", "August", "September",
"October", "November", "December"];
@endphp
<select name="month"
id="month"
class="form-select form-select-lg select-2 select-month"
data-placeholder="Choose Month">
<option></option>
@foreach($monthArr as $key=>$month)
@php
if ($key<9){
$number = "0".$key+1;
}else{
$number = $key+1;
}
@endphp
<option value="{{ $number }}">{{ $month }}</option>
@endforeach
</select>
</div>
<div class="mb-3">
<select name="year"
id="year"
class="form-select form-select-lg select-2 select-year"
data-placeholder="Choose Year">
<option value=""></option>
@for($i = 0; $i<15; $i++)
<option value="{{ now()->addYears(5)->subYear($i)->format('Y') }}">
{{ now()->addYears(5)->subYear($i)->format('Y') }}
</option>
@endfor
</select>
</div>
<div class="form-floating mb-3">
<input type="text" class="form-control"
id="amount" name="amount" placeholder="title">
<label for="amount">Amount (MMK)</label>
</div>
</div>
<div class="col-12 col-md-6 my-3">
<button class="btn btn-primary w-100">Save Salary</button>
</div>
</form>
</div>
</div>
@endsection
@section('js')
{!! JsValidator::formRequest('App\Http\Requests\StoreSalaryRequest','#create-department') !!}
<script>
$(document).ready(function (){
$( '.select-2' ).select2( {
theme: "bootstrap-5",
width: $( this ).data( 'width' ) ? $( this ).data( 'width' ) : $( this ).hasClass( 'w-100' ) ? '100%' : 'style',
placeholder: $( this ).data( 'placeholder' ),
allowClear: true
} );
});
</script>
@endsection
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# Edit.Blade
resources / views / Salary / edit.blade.php
@extends('layouts.master')
@section('page-title') Salary @endsection
@section('content')
<div class="mb-2">
<nav aria-label="breadcrumb" class="bg-white p-2 shadow-sm rounded">
<ol class="breadcrumb mb-0">
<li class="breadcrumb-item">
<a href="{{ route('salary.index') }}" class="text-decoration-none">Salary</a>
</li>
<li class="breadcrumb-item active" aria-current="page">Edit Salary</li>
</ol>
</nav>
</div>
<div class="card border-0 shadow-sm rounded">
<div class="card-body">
<div class="d-flex justify-content-between align-items-center">
<h4 class="fw-bold text-black-50 mb-0">
<i class="fa-solid fa-square-plus me-1"></i>Edit Salary
</h4>
<a href="{{ route('salary.index') }}" class="btn btn-outline-primary">
<i class="fa-solid fa-list"></i>
</a>
</div>
<hr>
<form action="{{ route('salary.update', $salary->id) }}"
method="post" id="create-department"
class="row justify-content-center py-2">
@csrf
@method('put')
<div class="col-12 col-md-8">
<div class="mb-3">
<select class="form-select form-select-lg select-2"
data-placeholder="Choose Employee's Name"
name="user">
<option></option>
@forelse($employees as $e)
<option value="{{ $e->id }}"
@if( old('user',$salary->user_id) == $e->id) selected @endif>
{{ $e->name }} ( {{ $e->employee_id }} )
</option>
@empty
@endforelse
</select>
</div>
<div class="mb-3">
@php
$monthArr = ["January", "February", "March",
"April", "May", "June",
"July", "August", "September",
"October", "November", "December"];
@endphp
<select name="month"
id="month"
class="form-select form-select-lg select-2 select-month"
data-placeholder="Choose Month">
<option></option>
@foreach($monthArr as $key=>$month)
@php
if ($key<9){
$number = "0".$key+1;
}else{
$number = $key+1;
}
@endphp
<option value="{{ $number }}" @if( $salary->month == $number) selected @endif>{{ $month }}</option>
@endforeach
</select>
</div>
<div class="mb-3">
<select name="year"
id="year"
class="form-select form-select-lg select-2 select-year"
data-placeholder="Choose Year">
<option value=""></option>
@for($i = 0; $i<15; $i++)
<option value="{{ now()->addYears(5)->subYear($i)->format('Y') }}" @if($salary->year == now()->addYears(5)->subYear($i)->format('Y') ) selected @endif>
{{ now()->addYears(5)->subYear($i)->format('Y') }}
</option>
@endfor
</select>
</div>
<div class="form-floating mb-3">
<input type="text" class="form-control" value="{{ $salary->amount }}"
id="amount" name="amount" placeholder="title">
<label for="amount">Amount (MMK)</label>
</div>
</div>
<div class="col-12 col-md-6 my-3">
<button class="btn btn-primary w-100">Save Salary</button>
</div>
</form>
</div>
</div>
@endsection
@section('js')
{!! JsValidator::formRequest('App\Http\Requests\UpdateSalaryRequest','#create-department') !!}
<script>
$(document).ready(function (){
$( '.select-2' ).select2( {
theme: "bootstrap-5",
width: $( this ).data( 'width' ) ? $( this ).data( 'width' ) : $( this ).hasClass( 'w-100' ) ? '100%' : 'style',
placeholder: $( this ).data( 'placeholder' ),
allowClear: true
} );
});
</script>
@endsection
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
← Permission PDF →