You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

154 lines
7.2 KiB
PHTML

@extends('layouts.admin')
@section('content')
<div class="card card-default">
<form id="writeForm" method="post" accept-charset="utf-8" enctype="multipart/form-data" action="{{ route('cms.partner.store', null, false) }}">
<input type="hidden" name="_token" value="{{ csrf_token() }}" />
<input type="hidden" name="mode" value="{{ $data->mode }}" />
<input type="hidden" name="uid" value="{{ $data->uid }}" />
<input type="hidden" name="category" value="{{ $data->category }}" />
<div class="card-header">
<h3 class="card-title">업체정보 입력</h3>
</div>
<div class="card-body">
<div class="panel-content">
<div class="profile-image elevation-4">
<input type="file" name="image" id="profile-file" class="profile-file" accept="image/gif,image/jpeg,image/png" />
@if ($data->image)
<a class="imgContainer-fit" href="{{ route('image', [$data->image], false) }}" data-fancybox="gallery"><img id="profileImage" src="{{ route('image.thumbnail.rate', ['h100', $data->image], false) }}" alt="" /></a>
@else
<a class="imgContainer-fit" href="javascript:;" style="cursor:default;"><img id="profileImage" src="/assets/img/none.png" style="border:1px solid #ddd;" alt="" /></a>
@endif
<span class="btn-profile elevation-3">@if ($data->uid)이미지 변경@else이미지 등록@endif</span>
</div>
<div class="form-group">
<label for="title">업체명</label>
<input type="text" class="form-control with-profile" name="title" id="title" required value="{{ $data->title }}" />
</div>
<div class="form-group">
<label for="link">링크주소</label>
<input type="text" class="form-control with-profile" name="link" id="link" value="{{ $data->link }}" />
</div>
<div class="form-group">
<label for="status-1">노출여부</label>
<div class="form-group-box">
<div class="custom-control custom-radio custom-control-inline">
<input type="radio" id="status-1" class="custom-control-input" name="status" value="1" {{ $data->status ? 'checked="checked "' : '' }}/>
<label for="status-1" class="custom-control-label">노출</label>
</div>
<div class="custom-control custom-radio custom-control-inline">
<input type="radio" id="status-0" class="custom-control-input" name="status" value="0" {{ !$data->status ? 'checked="checked "' : '' }}/>
<label for="status-0" class="custom-control-label">미노출</label>
</div>
</div>
</div>
@if($data->uid)
<div class="form-group">
<label for="created_at">등록일시</label>
<input type="text" class="form-control" id="created_at" disabled="disabled" value="{{ $data->created_at }}" />
</div>
@endif
</div>
</div>
<div class="card-footer">
<div class="row justify-content-between">
<span><a href="javascript:;" onclick="gotoList();" class="btn btn-primary btn-list"> 목록 </a></span>
<span>
<button type="submit" class="btn btn-success ml-2">@if($data->mode == 'modify') 수정 @else 등록 @endif</button>
@if($data->mode == 'modify')
<a href="{{ route('cms.partner.delete', null, false) }}" class="btn btn-secondary ml-2 btn-delete">삭제</a>
@endif
</span>
</div>
</div>
</form>
</div>
@stop
@push('scripts')
<script type="text/javascript">
function gotoList() {
window.location.href = '{{ route('cms.partner.list', null, false) }}';
}
// 사진 미리보기
function selectProfile(files) {
if (!files || !files[0]) {
alert('파일이 선택되지 않았습니다.');
return false;
}
var reader = new FileReader();
reader.onload = function(e) {
$('#profileImage').attr('src', e.target.result);
$('#profileImage').parent().attr({
'href': e.target.result,
'data-fancybox': 'gallery'
}).css('cursor', 'pointer');
};
reader.readAsDataURL(files[0]);
}
$(document).ready(function() {
// 프로필 사진 첨부
$('#profile-file').bind('change', function() {
selectProfile(this.files);
});
$('.btn-profile').on('click', function() {
$('#profile-file').click();
});
$('#writeForm').submit(function () {
if (!$("#title").checkEmpty('업체명을 입력해 주세요.')) return false;
if (!$("input[name=uid]").val()) {
if (!$("#profile-file").checkEmpty('이미지를 업로드해 주세요.')) return false;
}
var formData = new FormData(this);
$.ajax({
url : $(this).attr('action'),
type : 'post',
enctype : 'multipart/form-data',
processData : false,
contentType : false,
data : formData,
success : function(result) {
alert(result.message);
if (result.success) {
gotoList();
}
},
error : function(result) {
var data = result.responseJSON;
if (!data.success) {
alert(data.message);
}
}
});
return false;
});
$('.btn-delete').click(function() {
if(confirm('업체정보를 삭제하시겠습니까?')) {
$.post($(this).attr('href'), {'uid': $('#writeForm input[name=uid]').val()}, function (result) {
if (result.success) {
gotoList();
} else {
alert(result.message);
}
}).fail(function(result) {
var data = result.responseJSON;
if (!data.success) {
alert(data.message);
}
});
}
return false;
});
});
</script>
@endpush