440 lines
14 KiB
PHP
440 lines
14 KiB
PHP
<script>
|
|
$(document).ready(function () {
|
|
getData();
|
|
|
|
reInitForm();
|
|
|
|
$("#formData").bootstrapValidator({
|
|
excluded: [':disabled'],
|
|
feedbackIcons: {
|
|
valid: 'glyphicon glyphicon-ok',
|
|
invalid: 'glyphicon glyphicon-remove',
|
|
validating: 'glyphicon glyphicon-refresh'
|
|
},
|
|
fields: {
|
|
banner_img1: {
|
|
validators: {
|
|
file: {
|
|
extension: 'jpg,jpeg,png',
|
|
type: 'image/jpg,image/jpeg,image/png',
|
|
maxSize: 0.25 * (1024*1024),
|
|
message: 'File Tidak Sesuai'
|
|
}
|
|
}
|
|
},
|
|
banner_img2: {
|
|
validators: {
|
|
file: {
|
|
extension: 'jpg,jpeg,png',
|
|
type: 'image/jpg,image/jpeg,image/png',
|
|
maxSize: 0.25 * (1024*1024),
|
|
message: 'File Tidak Sesuai'
|
|
}
|
|
}
|
|
},
|
|
banner_img3: {
|
|
validators: {
|
|
file: {
|
|
extension: 'jpg,jpeg,png',
|
|
type: 'image/jpg,image/jpeg,image/png',
|
|
maxSize: 0.25 * (1024*1024),
|
|
message: 'File Tidak Sesuai'
|
|
}
|
|
}
|
|
},
|
|
img_biking: {
|
|
validators: {
|
|
file: {
|
|
extension: 'jpg,jpeg,png',
|
|
type: 'image/jpg,image/jpeg,image/png',
|
|
maxSize: 0.25 * (1024*1024),
|
|
message: 'File Tidak Sesuai'
|
|
}
|
|
}
|
|
},
|
|
img_esport: {
|
|
validators: {
|
|
file: {
|
|
extension: 'jpg,jpeg,png',
|
|
type: 'image/jpg,image/jpeg,image/png',
|
|
maxSize: 0.25 * (1024*1024),
|
|
message: 'File Tidak Sesuai'
|
|
}
|
|
}
|
|
},
|
|
img_onfield: {
|
|
validators: {
|
|
file: {
|
|
extension: 'jpg,jpeg,png',
|
|
type: 'image/jpg,image/jpeg,image/png',
|
|
maxSize: 0.25 * (1024*1024),
|
|
message: 'File Tidak Sesuai'
|
|
}
|
|
}
|
|
},
|
|
hot_item_img: {
|
|
validators: {
|
|
file: {
|
|
extension: 'jpg,jpeg,png',
|
|
type: 'image/jpg,image/jpeg,image/png',
|
|
maxSize: 0.25 * (1024*1024),
|
|
message: 'File Tidak Sesuai'
|
|
}
|
|
}
|
|
},
|
|
hot_item_desc: {
|
|
validators: {
|
|
notEmpty: {
|
|
message: 'Tidak Boleh Kosong'
|
|
}
|
|
}
|
|
},
|
|
hot_item_katalog_id: {
|
|
validators: {
|
|
notEmpty: {
|
|
message: 'Tidak Boleh Kosong'
|
|
}
|
|
}
|
|
},
|
|
|
|
banner_title1: {
|
|
validators: {
|
|
notEmpty: {
|
|
message: 'Tidak Boleh Kosong'
|
|
},
|
|
stringLength: {
|
|
max:50,
|
|
message: 'Maksimal 50 Karakter'
|
|
}
|
|
}
|
|
},
|
|
banner_title2: {
|
|
validators: {
|
|
notEmpty: {
|
|
message: 'Tidak Boleh Kosong'
|
|
},
|
|
stringLength: {
|
|
max:50,
|
|
message: 'Maksimal 50 Karakter'
|
|
}
|
|
}
|
|
},
|
|
banner_title3: {
|
|
validators: {
|
|
notEmpty: {
|
|
message: 'Tidak Boleh Kosong'
|
|
},
|
|
stringLength: {
|
|
max:50,
|
|
message: 'Maksimal 50 Karakter'
|
|
}
|
|
}
|
|
},
|
|
banner_desc1: {
|
|
validators: {
|
|
notEmpty: {
|
|
message: 'Tidak Boleh Kosong'
|
|
},
|
|
stringLength: {
|
|
max:100,
|
|
message: 'Maksimal 100 Karakter'
|
|
}
|
|
}
|
|
},
|
|
banner_desc2: {
|
|
validators: {
|
|
notEmpty: {
|
|
message: 'Tidak Boleh Kosong'
|
|
},
|
|
stringLength: {
|
|
max:100,
|
|
message: 'Maksimal 100 Karakter'
|
|
}
|
|
}
|
|
},
|
|
banner_desc3: {
|
|
validators: {
|
|
notEmpty: {
|
|
message: 'Tidak Boleh Kosong'
|
|
},
|
|
stringLength: {
|
|
max:100,
|
|
message: 'Maksimal 100 Karakter'
|
|
}
|
|
}
|
|
},
|
|
banner_tag1: {
|
|
validators: {
|
|
notEmpty: {
|
|
message: 'Tidak Boleh Kosong'
|
|
},
|
|
stringLength: {
|
|
max:30,
|
|
message: 'Maksimal 30 Karakter'
|
|
}
|
|
}
|
|
},
|
|
banner_tag2: {
|
|
validators: {
|
|
notEmpty: {
|
|
message: 'Tidak Boleh Kosong'
|
|
},
|
|
stringLength: {
|
|
max:30,
|
|
message: 'Maksimal 30 Karakter'
|
|
}
|
|
}
|
|
},
|
|
banner_tag3: {
|
|
validators: {
|
|
notEmpty: {
|
|
message: 'Tidak Boleh Kosong'
|
|
},
|
|
stringLength: {
|
|
max:30,
|
|
message: 'Maksimal 30 Karakter'
|
|
}
|
|
}
|
|
},
|
|
banner_link1: {
|
|
validators: {
|
|
notEmpty: {
|
|
message: 'Tidak Boleh Kosong'
|
|
},
|
|
stringLength: {
|
|
max:100,
|
|
message: 'Maksimal 100 Karakter'
|
|
}
|
|
}
|
|
},
|
|
banner_link2: {
|
|
validators: {
|
|
notEmpty: {
|
|
message: 'Tidak Boleh Kosong'
|
|
},
|
|
stringLength: {
|
|
max:100,
|
|
message: 'Maksimal 100 Karakter'
|
|
}
|
|
}
|
|
},
|
|
banner_link3: {
|
|
validators: {
|
|
notEmpty: {
|
|
message: 'Tidak Boleh Kosong'
|
|
},
|
|
stringLength: {
|
|
max:100,
|
|
message: 'Maksimal 100 Karakter'
|
|
}
|
|
}
|
|
},
|
|
|
|
produk_pilihan1: {
|
|
validators: {
|
|
notEmpty: {
|
|
message: 'Tidak Boleh Kosong'
|
|
}
|
|
}
|
|
},
|
|
produk_pilihan2: {
|
|
validators: {
|
|
notEmpty: {
|
|
message: 'Tidak Boleh Kosong'
|
|
}
|
|
}
|
|
},
|
|
produk_pilihan3: {
|
|
validators: {
|
|
notEmpty: {
|
|
message: 'Tidak Boleh Kosong'
|
|
}
|
|
}
|
|
},
|
|
dropdown_alliance: {
|
|
validators: {
|
|
file: {
|
|
extension: 'jpg,jpeg,png',
|
|
type: 'image/jpg,image/jpeg,image/png',
|
|
maxSize: 0.25 * (1024*1024),
|
|
message: 'File Tidak Sesuai'
|
|
}
|
|
}
|
|
},
|
|
banner_produk_terbaik: {
|
|
validators: {
|
|
file: {
|
|
extension: 'jpg,jpeg,png',
|
|
type: 'image/jpg,image/jpeg,image/png',
|
|
maxSize: 0.25 * (1024*1024),
|
|
message: 'File Tidak Sesuai'
|
|
}
|
|
}
|
|
},
|
|
|
|
}
|
|
|
|
}).on('success.field.bv', function (e, data) {
|
|
var $parent = data.element.parents('.form-group');
|
|
$parent.removeClass('has-success');
|
|
$parent.find('.form-control-feedback[data-bv-icon-for="' + data.field + '"]').hide();
|
|
});
|
|
|
|
})
|
|
|
|
|
|
function clearImage() {
|
|
let imageUrl = '{{asset('img/no_img.png')}}';
|
|
|
|
$('#ava1').css("background-image", "url(" + imageUrl + ")");
|
|
$('#banner_img1').val('');
|
|
$('#pic-cancel').hide();
|
|
|
|
$('#ava2').css("background-image", "url(" + imageUrl + ")");
|
|
$('#banner_img2').val('');
|
|
$('#pic-cancel2').hide();
|
|
|
|
$('#ava3').css("background-image", "url(" + imageUrl + ")");
|
|
$('#banner_img3').val('');
|
|
$('#pic-cancel3').hide();
|
|
|
|
$('#ava_img_biking').css("background-image", "url(" + imageUrl + ")");
|
|
$('#img_biking').val('');
|
|
$('#pic-cancel4').hide();
|
|
|
|
$('#ava_img_esport').css("background-image", "url(" + imageUrl + ")");
|
|
$('#img_esport').val('');
|
|
$('#pic-cancel5').hide();
|
|
|
|
$('#ava_img_onfield').css("background-image", "url(" + imageUrl + ")");
|
|
$('#img_onfield').val('');
|
|
$('#pic-cancel6').hide();
|
|
|
|
$('#ava_hot_item_img').css("background-image", "url(" + imageUrl + ")");
|
|
$('#hot_item_img').val('');
|
|
$('#pic-cancel6').hide();
|
|
|
|
$('#ava_produk_pilihan_background').css("background-image", "url(" + imageUrl + ")");
|
|
$('#produk_pilihan_background').val('');
|
|
$('#pic-cancel7').hide();
|
|
|
|
$('#ava_dropdown_alliance').css("background-image", "url(" + imageUrl + ")");
|
|
$('#dropdown_alliance').val('');
|
|
$('#pic-cancel8').hide();
|
|
}
|
|
|
|
|
|
function store() {
|
|
|
|
let myForm = document.getElementById('formData');
|
|
let formData = new FormData(myForm);
|
|
|
|
znLoadingPage();
|
|
doPost(base_url+'management_content/act_any/store_home', formData, function (msg, res) {
|
|
//console.log(res);
|
|
|
|
if (res == null){
|
|
znNotif("danger", msg);
|
|
}else {
|
|
if(res.rc == 0){
|
|
znNotif('success','Berhasil Menyimpan Data');
|
|
}else{
|
|
znNotif("danger", res.rm);
|
|
}
|
|
}
|
|
znLoadingPageEnd();
|
|
|
|
})
|
|
}
|
|
|
|
function getData() {
|
|
znLoadingPage();
|
|
clearImage();
|
|
var avatar1 = new KTImageInput('kt_image_1');
|
|
var avatar2 = new KTImageInput('kt_image_2');
|
|
var avatar3 = new KTImageInput('kt_image_3');
|
|
var avatar4 = new KTImageInput('kt_image_img_esport');
|
|
var avatar5 = new KTImageInput('kt_image_img_onfield');
|
|
var avatar6 = new KTImageInput('kt_image_img_biking');
|
|
var avatar7 = new KTImageInput('kt_image_hot_item_img');
|
|
var avatar8 = new KTImageInput('kt_image_produk_pilihan_background');
|
|
var avatar9 = new KTImageInput('kt_image_dropdown_alliance');
|
|
|
|
let formData = new FormData();
|
|
formData.append('id',1);
|
|
doPost(base_url+'management_content/act_any/get_home', formData, function (msg, res) {
|
|
znLoadingPageEnd();
|
|
|
|
//console.log(res);
|
|
var data = res.data;
|
|
|
|
$('#banner_title1').val(data.banner_title1);
|
|
$('#banner_title2').val(data.banner_title2);
|
|
$('#banner_title3').val(data.banner_title3);
|
|
$('#banner_desc1').val(data.banner_desc1);
|
|
$('#banner_desc2').val(data.banner_desc2);
|
|
$('#banner_desc3').val(data.banner_desc3);
|
|
$('#banner_tag1').val(data.banner_tag1);
|
|
$('#banner_tag2').val(data.banner_tag2);
|
|
$('#banner_tag3').val(data.banner_tag3);
|
|
$('#banner_link1').val(data.banner_link1);
|
|
$('#banner_link2').val(data.banner_link2);
|
|
$('#banner_link3').val(data.banner_link3);
|
|
$('#hot_item_desc').val(data.hot_item_desc);
|
|
|
|
$('#produk_pilihan1').val(data.produk_pilihan1).trigger('change.select2');
|
|
$('#produk_pilihan2').val(data.produk_pilihan2).trigger('change.select2');
|
|
$('#produk_pilihan3').val(data.produk_pilihan3).trigger('change.select2');
|
|
$('#hot_item_katalog_id').val(data.hot_item_katalog_id).trigger('change.select2');
|
|
|
|
if(data.banner_img1){
|
|
var imageUrl = "{{asset('gallery')}}/"+data.banner_img1;
|
|
$('#ava1').css("background-image", "url(" + imageUrl + ")");
|
|
}
|
|
|
|
if(data.banner_img2){
|
|
var imageUrl = "{{asset('gallery')}}/"+data.banner_img2;
|
|
$('#ava2').css("background-image", "url(" + imageUrl + ")");
|
|
}
|
|
|
|
if(data.banner_img3){
|
|
var imageUrl = "{{asset('gallery')}}/"+data.banner_img3;
|
|
$('#ava3').css("background-image", "url(" + imageUrl + ")");
|
|
}
|
|
|
|
if(data.img_biking){
|
|
var imageUrl = "{{asset('gallery')}}/"+data.img_biking;
|
|
$('#ava_img_biking').css("background-image", "url(" + imageUrl + ")");
|
|
}
|
|
|
|
if(data.img_esport){
|
|
var imageUrl = "{{asset('gallery')}}/"+data.img_esport;
|
|
$('#ava_img_esport').css("background-image", "url(" + imageUrl + ")");
|
|
}
|
|
|
|
if(data.img_onfield){
|
|
var imageUrl = "{{asset('gallery')}}/"+data.img_onfield;
|
|
$('#ava_img_onfield').css("background-image", "url(" + imageUrl + ")");
|
|
}
|
|
|
|
if(data.hot_item_img){
|
|
var imageUrl = "{{asset('gallery')}}/"+data.hot_item_img;
|
|
$('#ava_hot_item_img').css("background-image", "url(" + imageUrl + ")");
|
|
}
|
|
|
|
if(data.produk_pilihan_background){
|
|
var imageUrl = "{{asset('gallery')}}/"+data.produk_pilihan_background;
|
|
$('#ava_produk_pilihan_background').css("background-image", "url(" + imageUrl + ")");
|
|
}
|
|
|
|
if(data.dropdown_alliance){
|
|
var imageUrl = "{{asset('gallery')}}/"+data.dropdown_alliance;
|
|
$('#ava_dropdown_alliance').css("background-image", "url(" + imageUrl + ")");
|
|
}
|
|
|
|
|
|
|
|
$('#formData').data('bootstrapValidator').validate();
|
|
})
|
|
}
|
|
</script> |