1@extends('backend.layouts.master')
2
3@section('title')
4Thêm mới sản phẩm
5@endsection
6
7@section('custom-css')
8<!-- Các css dành cho thư viện bootstrap-fileinput -->
9<link href="{{ asset('vendor/bootstrap-fileinput/css/fileinput.css') }}" media="all" rel="stylesheet" type="text/css" />
10<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.5.0/css/all.css" crossorigin="anonymous">
11<link href="{{ asset('vendor/bootstrap-fileinput/themes/explorer-fas/theme.css') }}" media="all" rel="stylesheet" type="text/css" />
12@endsection
13
14@section('content')
15@if ($errors->any())
16<div class="alert alert-danger">
17 <ul>
18 @foreach ($errors->all() as $error)
19 <li>{{ $error }}</li>
20 @endforeach
21 </ul>
22</div>
23@endif
24
25<form method="post" action="{{ route('admin.sanpham.store') }}" enctype="multipart/form-data">
26 {{ csrf_field() }}
27 <div class="form-group">
28 <label for="l_ma">Loại sản phẩm</label>
29 <select name="l_ma" class="form-control">
30 @foreach($danhsachloai as $loai)
31 @if(old('l_ma') == $loai->l_ma)
32 <option value="{{ $loai->l_ma }}" selected>{{ $loai->l_ten }}</option>
33 @else
34 <option value="{{ $loai->l_ma }}">{{ $loai->l_ten }}</option>
35 @endif
36 @endforeach
37 </select>
38 </div>
39 <div class="form-group">
40 <label for="sp_ten">Tên sản phẩm</label>
41 <input type="text" class="form-control" id="sp_ten" name="sp_ten" value="{{ old('sp_ten') }}">
42 </div>
43 <div class="form-group">
44 <label for="sp_giaGoc">Giá gốc</label>
45 <input type="text" class="form-control" id="sp_giaGoc" name="sp_giaGoc" value="{{ old('sp_giaGoc') }}">
46 </div>
47 <div class="form-group">
48 <label for="sp_giaGoc">Giá bán</label>
49 <input type="text" class="form-control" id="sp_giaBan" name="sp_giaBan" value="{{ old('sp_giaBan') }}">
50 </div>
51 <div class="form-group">
52 <div class="file-loading">
53 <label>Hình đại diện</label>
54 <input id="sp_hinh" type="file" name="sp_hinh">
55 </div>
56 </div>
57 <div class="form-group">
58 <label for="sp_thongTin">Thông tin</label>
59 <input type="text" class="form-control" id="sp_thongTin" name="sp_thongTin" value="{{ old('sp_thongTin') }}">
60 </div>
61 <div class="form-group">
62 <label for="sp_danhGia">Đánh giá</label>
63 <input type="text" class="form-control" id="sp_danhGia" name="sp_danhGia" value="{{ old('sp_danhGia') }}">
64 </div>
65 <div class="form-group">
66 <label for="sp_taoMoi">Ngày tạo mới</label>
67 <input type="text" class="form-control" id="sp_taoMoi" name="sp_taoMoi" value="{{ old('sp_taoMoi') }}">
68 </div>
69 <div class="form-group">
70 <label for="sp_capNhat">Ngày cập nhật</label>
71 <input type="text" class="form-control" id="sp_capNhat" name="sp_capNhat" value="{{ old('sp_capNhat') }}">
72 </div>
73 <div class="form-group">
74 <label for="sp_trangThai">Trạng thái</label>
75 <select name="sp_trangThai" class="form-control">
76 <option value="1" {{ old('sp_trangThai') == 1 ? "selected" : "" }}>Khóa</option>
77 <option value="2" {{ old('sp_trangThai') == 2 ? "selected" : "" }}>Khả dụng</option>
78 </select>
79 </div>
80 <button type="submit" class="btn btn-primary">Lưu</button>
81</form>
82@endsection
83
84@section('custom-scripts')
85<!-- Các script dành cho thư viện bootstrap-fileinput -->
86<script src="{{ asset('vendor/bootstrap-fileinput/js/plugins/sortable.js') }}" type="text/javascript"></script>
87<script src="{{ asset('vendor/bootstrap-fileinput/js/fileinput.js') }}" type="text/javascript"></script>
88<script src="{{ asset('vendor/bootstrap-fileinput/js/locales/fr.js') }}" type="text/javascript"></script>
89<script src="{{ asset('vendor/bootstrap-fileinput/themes/fas/theme.js') }}" type="text/javascript"></script>
90<script src="{{ asset('vendor/bootstrap-fileinput/themes/explorer-fas/theme.js') }}" type="text/javascript"></script>
91
92<script>
93 $(document).ready(function() {
94 $("#sp_hinh").fileinput({
95 theme: 'fas',
96 showUpload: false,
97 showCaption: false,
98 browseClass: "btn btn-primary btn-lg",
99 fileType: "any",
100 previewFileIcon: "<i class='glyphicon glyphicon-king'></i>",
101 overwriteInitial: false
102 });
103 });
104</script>
105
106<!-- Các script dành cho thư viện Mặt nạ nhập liệu InputMask -->
107<script src="{{ asset('vendor/input-mask/jquery.inputmask.min.js') }}"></script>
108<script src="{{ asset('vendor/input-mask/bindings/inputmask.binding.js') }}"></script>
109
110<script>
111 $(document).ready(function() {
112 // Gắn mặt nạ nhập liệu cho các ô nhập liệu Giá gốc
113 $('#sp_giaGoc').inputmask({
114 alias: 'currency',
115 positionCaretOnClick: "radixFocus",
116 radixPoint: ".",
117 _radixDance: true,
118 numericInput: true,
119 groupSeparator: ",",
120 suffix: ' vnđ',
121 min: 0, // 0 ngàn
122 max: 100000000, // 1 trăm triệu
123 autoUnmask: true,
124 removeMaskOnSubmit: true,
125 unmaskAsNumber: true,
126 inputtype: 'text',
127 placeholder: "0",
128 definitions: {
129 "0": {
130 validator: "[0-9\uFF11-\uFF19]"
131 }
132 }
133 });
134
135 // Gắn mặt nạ nhập liệu cho các ô nhập liệu Giá bán
136 $('#sp_giaBan').inputmask({
137 alias: 'currency',
138 positionCaretOnClick: "radixFocus",
139 radixPoint: ".",
140 _radixDance: true,
141 numericInput: true,
142 groupSeparator: ",",
143 suffix: ' vnđ',
144 min: 0, // 0 ngàn
145 max: 100000000, // 1 trăm triệu
146 autoUnmask: true,
147 removeMaskOnSubmit: true,
148 unmaskAsNumber: true,
149 inputtype: 'text',
150 placeholder: "0",
151 definitions: {
152 "0": {
153 validator: "[0-9\uFF11-\uFF19]"
154 }
155 }
156 });
157
158 // Gắn mặt nạ nhập liệu cho các ô nhập liệu Ngày tạo mới
159 $('#sp_taoMoi').inputmask({
160 alias: 'datetime',
161 inputFormat: 'yyyy-mm-dd' // Định dạng Năm-Tháng-Ngày
162 });
163
164 // Gắn mặt nạ nhập liệu cho các ô nhập liệu Ngày cập nhật
165 $('#sp_capNhat').inputmask({
166 alias: 'datetime',
167 inputFormat: 'yyyy-mm-dd' // Định dạng Năm-Tháng-Ngày
168 });
169 });
170</script>
171
172@endsection