Instantly share code, notes, and snippets.
Last active
May 4, 2019 08:29
-
Star
(0)
0
You must be signed in to star a gist -
Fork
(0)
0
You must be signed in to fork a gist
-
Save khaeransori/4e6505f773d3a987045046c24feaab8a to your computer and use it in GitHub Desktop.
footerHabibi.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
</div> | |
<!-- /#wrapper --> | |
<!-- jQuery --> | |
<script src="<?php echo base_url(); ?>assets/vendor/jquery/jquery3.min.js"></script> | |
<script src="<?php echo base_url(); ?>assets/vendor/jquery/typeahead.js"></script> | |
<!-- Bootstrap Core JavaScript --> | |
<script src="<?php echo base_url(); ?>assets/vendor/bootstrap/js/bootstrap.min.js"></script> | |
<!-- Metis Menu Plugin JavaScript --> | |
<script src="<?php echo base_url(); ?>assets/vendor/metisMenu/metisMenu.min.js"></script> | |
<!-- Morris Charts JavaScript --> | |
<script src="<?php echo base_url(); ?>assets/vendor/raphael/raphael.min.js"></script> | |
<!-- Custom Theme JavaScript --> | |
<script src="<?php echo base_url(); ?>assets/dist/js/sb-admin-2.js"></script> | |
<!-- jQuery --> | |
<script src="<?php echo base_url(); ?>assets/dist/js/summernote.js"></script> | |
<!-- DataTables JavaScript --> | |
<script src="<?php echo base_url(); ?>assets/vendor/datatables/js/jquery.dataTables.min.js"></script> | |
<script src="<?php echo base_url(); ?>assets/vendor/datatables-plugins/dataTables.bootstrap.min.js"></script> | |
<script src="<?php echo base_url(); ?>assets/vendor/datatables-responsive/dataTables.responsive.js"></script> | |
<script src="<?php echo base_url(); ?>assets/modify/style.js" type="text/javascript"></script> | |
<script src="<?php echo base_url(); ?>assets/dist/js/bootstrap-datepicker.js"></script> | |
<script src="<?php echo base_url(); ?>assets/dist/js/bootstrap-datepicker.id.js"></script> | |
<script src="<?php echo base_url(); ?>assets/highcharts/code/highcharts.js"></script> | |
<script src="<?php echo base_url(); ?>assets/highcharts/code/modules/exporting.js"></script> | |
<script src="<?php echo base_url(); ?>assets/highcharts/code/modules/export-data.js"></script> | |
<script src="<?php echo base_url(); ?>assets/global/plugins/select2/select2.min.js"></script> | |
<script src="<?php echo base_url(); ?>assets/shared/FieldRepeater.js" type="text/javascript"></script> | |
<script type="text/javascript"> | |
function countOrderByDay(){ | |
var baseUrl = "<?php echo base_url() ?>"; | |
$.ajax({ | |
type:"POST", | |
url: baseUrl+"AnalyzerController/countOrderByDay", | |
dataType:"json", | |
cache:false, | |
success: function(data){ | |
if(data.result== 200){ | |
var day = [ | |
['1',0], | |
['2',0], | |
['3',0], | |
['4',0], | |
['5',0], | |
['6',0], | |
['7',0], | |
]; | |
for (var i = 0; i < 7; i++) { | |
for (var j = 0; j < data.dataOrder.length;j++) { | |
if(day[i][0] == data.dataOrder[j]['day_name']){ | |
day[i][1] = parseInt(data.dataOrder[j]['total_order']); | |
} | |
} | |
} | |
Highcharts.chart('selling-cart-by-day-container', { | |
chart: { | |
type: 'column' | |
}, | |
title: { | |
text: 'GRAFIK PENJUALAN BERDASARKAN HARI' | |
}, | |
subtitle: { | |
text: 'source - data order' | |
}, | |
xAxis: { | |
categories: [ | |
'Senin', | |
'Selasa', | |
'Rabu', | |
'Kamis', | |
'Jumat', | |
'Sabtu', | |
'Minggu' | |
], | |
crosshair: true | |
}, | |
yAxis: { | |
min: 0, | |
title: { | |
text: 'Jumlah (Pcs)' | |
} | |
}, | |
tooltip: { | |
headerFormat: '<span style="font-size:10px">{point.key}</span><table>', | |
pointFormat: '<tr><td style="color:{series.color};padding:0">{series.name}: </td>' + | |
'<td style="padding:0"><b>{point.y:.1f} pcs</b></td></tr>', | |
footerFormat: '</table>', | |
shared: true, | |
useHTML: true | |
}, | |
plotOptions: { | |
column: { | |
pointPadding: 0.2, | |
borderWidth: 0 | |
} | |
}, | |
series: [{ | |
name: 'Total Penjualan', | |
data: [day[0][1],day[1][1],day[2][1],day[3][1],day[4][1],day[5][1],day[6][1]] | |
}] | |
}); | |
}else{ | |
var errorMessage = document.getElementById('error-message'); | |
removeChildElements('error-message'); | |
errorMessage.appendChild(document.createTextNode('Data jumlah penjualan berdasarkan hari tidak dapat ditampilkan')); | |
$('#errorMessage').modal('show'); | |
} | |
}, | |
error: function(xhr, status, error) { | |
var errorMessage = document.getElementById('error-message'); | |
removeChildElements('error-message'); | |
errorMessage.appendChild(document.createTextNode('Data jumlah penjualan berdasarkan hari tidak dapat ditampilkan : '+error)); | |
$('#errorMessage').modal('show'); | |
} | |
}); | |
} | |
if(document.getElementById('selling-cart-by-day-container')!=null){ | |
countOrderByDay(); | |
} | |
</script> | |
<script> | |
$('#textarea').summernote({ | |
toolbar: [ | |
// [groupName, [list of button]] | |
['style', ['bold', 'italic', 'underline', 'clear']], | |
['font', ['strikethrough', 'superscript', 'subscript']], | |
['fontsize', ['fontsize']], | |
['color', ['color']], | |
['para', ['ul', 'ol', 'paragraph']], | |
['height', ['height']] | |
], | |
height: 200 | |
}); | |
</script> | |
<script> | |
$(document).ready(function(){ | |
$('[data-toggle="tooltip"]').tooltip(); | |
}); | |
</script> | |
<script type="text/javascript"> | |
$(document).ready(function(){ | |
// $("#alert_success").hide(); | |
var date_input=$('input[name="invoiceDate"]'); //our date input has the name "date" | |
var container=$('.bootstrap-iso form').length>0 ? $('.bootstrap-iso form').parent() : "body"; | |
var options={ | |
format: 'dd MM yyyy', | |
container: container, | |
todayHighlight: true, | |
autoclose: true, | |
}; | |
date_input.datepicker(options); | |
}); | |
$(document).ready(function(){ | |
// $("#alert_success").hide(); | |
var date_input=$('input[name="startDate"]'); //our date input has the name "date" | |
var container=$('.bootstrap-iso form').length>0 ? $('.bootstrap-iso form').parent() : "body"; | |
var options={ | |
format: 'dd MM yyyy', | |
container: container, | |
todayHighlight: true, | |
autoclose: true, | |
}; | |
date_input.datepicker(options); | |
}); | |
$(document).ready(function(){ | |
// $("#alert_success").hide(); | |
var date_input=$('input[name="endDate"]'); //our date input has the name "date" | |
var container=$('.bootstrap-iso form').length>0 ? $('.bootstrap-iso form').parent() : "body"; | |
var options={ | |
format: 'dd MM yyyy', | |
container: container, | |
todayHighlight: true, | |
autoclose: true, | |
}; | |
date_input.datepicker(options); | |
}); | |
$(document).ready(function(){ | |
// $("#alert_success").hide(); | |
var date_input=$('input[name="expenseDate"]'); //our date input has the name "date" | |
var container=$('.bootstrap-iso form').length>0 ? $('.bootstrap-iso form').parent() : "body"; | |
var options={ | |
format: 'dd MM yyyy', | |
container: container, | |
todayHighlight: true, | |
autoclose: true, | |
}; | |
date_input.datepicker(options); | |
date_input.datepicker('setDate', new Date()); | |
}); | |
</script> | |
<script type="text/javascript"> | |
$(document).ready(function(){ | |
var date_input=$('input[name="orderDate"]'); //our date input has the name "date" | |
var container=$('.bootstrap-iso form').length>0 ? $('.bootstrap-iso form').parent() : "body"; | |
var options={ | |
format: 'dd MM yyyy', | |
container: container, | |
todayHighlight: true, | |
autoclose: true, | |
}; | |
date_input.datepicker(options); | |
}); | |
$(document).ready(function(){ | |
var date_input=$('input[name="transferDate"]'); //our date input has the name "date" | |
var container=$('.bootstrap-iso form').length>0 ? $('.bootstrap-iso form').parent() : "body"; | |
var options={ | |
format: 'dd MM yyyy', | |
container: container, | |
todayHighlight: true, | |
autoclose: true, | |
}; | |
date_input.datepicker(options); | |
}); | |
</script> | |
<script type="text/javascript"> | |
function readURL(input,idImage) { | |
// console.log(idImage); | |
if (input.files && input.files[0]) { | |
var reader = new FileReader(); | |
reader.onload = function (e) { | |
$('#'+idImage) | |
.attr('src', e.target.result) | |
.width(180) | |
.height(200); | |
}; | |
reader.readAsDataURL(input.files[0]); | |
} | |
} | |
</script> | |
<script> | |
$(document).ready(function() { | |
$('#dataTables-example').DataTable({ | |
pageLength: 10, | |
responsive: true | |
}); | |
}); | |
</script> | |
<script> | |
$('#updateSuplier').on('show.bs.modal', function(e) { | |
var $modal = $(this), | |
data = e.relatedTarget.id; | |
data = data.split("@"); | |
$("#idSuplier").val(data[0]); | |
$("#updateSuplierCode").val(data[1]); | |
$("#updateSuplierName").val(data[2]); | |
$("#updateShippingDestination").val(data[3]); | |
$("#updateAddress").val(data[4]); | |
$("#updatePhoneNumber").val(data[5]); | |
$("#updateDescription").val(data[6]); | |
}) | |
$('#updateExpense').on('show.bs.modal', function(e) { | |
var $modal = $(this), | |
data = e.relatedTarget.id; | |
data = data.split("@"); | |
$("#idExpense").val(data[0]); | |
$("#expenseUpdateTitle").val(data[1]); | |
$("#expenseUpdateNominal").val(data[2]); | |
$("#expenseUpdateQuantity").val(data[3]); | |
$("#expenseUpdateTotal").val(data[4]); | |
$("#expenseUpdateNote").val(data[5]); | |
$("#expenseUpdateDate").val(data[6]); | |
$("#categoryUpdate").val(data[7]+":"+data[8]); | |
}) | |
$('#deleteExpense').on('show.bs.modal', function(e) { | |
var $modal = $(this), | |
data = e.relatedTarget.id; | |
data = data.split("@"); | |
$("#idDeleteExpense").val(data[0]); | |
$("#expenseDeleteTitle").val(data[1]); | |
$("#expenseDeleteNominal").val(data[2]); | |
}) | |
$('#deleteSuplier').on('show.bs.modal', function(e) { | |
var $modal = $(this), | |
data = e.relatedTarget.id; | |
data = data.split("@"); | |
$("#deleteIdSuplier").val(data[0]); | |
$("#deleteSuplierCode").val(data[1]); | |
$("#deleteSuplierName").val(data[2]); | |
}) | |
$('#updateCategory').on('show.bs.modal', function(e) { | |
var $modal = $(this), | |
data = e.relatedTarget.id; | |
data = data.split("@"); | |
$("#updateCategoryId").val(data[0]); | |
$("#updateCategoryCode").val(data[1]); | |
$("#updateCategoryName").val(data[2]); | |
}) | |
$('#deleteCategory').on('show.bs.modal', function(e) { | |
var $modal = $(this), | |
data = e.relatedTarget.id; | |
data = data.split("@"); | |
$("#deleteCategoryId").val(data[0]); | |
$("#deleteCategoryCode").val(data[1]); | |
$("#deleteCategoryName").val(data[2]); | |
}) | |
$('#updateSubCategory').on('show.bs.modal', function(e) { | |
var $modal = $(this), | |
data = e.relatedTarget.id; | |
data = data.split("@"); | |
$("#updateSubCategoryId").val(data[0]); | |
$("#updateSubCategoryCode").val(data[1]); | |
$("#updateSubCategoryName").val(data[2]); | |
$("#updateCategoryId-sub").val(data[3]); | |
}) | |
$('#deleteSubCategory').on('show.bs.modal', function(e) { | |
var $modal = $(this), | |
data = e.relatedTarget.id; | |
data = data.split("@"); | |
$("#deleteSubCategoryId").val(data[0]); | |
$("#deleteSubCategoryCode").val(data[1]); | |
$("#deleteSubCategoryName").val(data[2]); | |
$("#deleteCategoryId-sub").val(data[3]); | |
}) | |
$('#deleteProduct').on('show.bs.modal', function(e) { | |
var $modal = $(this), | |
data = e.relatedTarget.id; | |
data = data.split("@"); | |
$("#idProductDelete").val(data[0]); | |
$("#productNameDelete").text(data[1]); | |
}) | |
$('#addPayment').on('show.bs.modal', function(e) { | |
var $modal = $(this), | |
data = e.relatedTarget.id; | |
data = data.split("@"); | |
if(data[0]!="no"){ | |
$("#paymentMethod").val(data[0]); | |
} | |
if(data[1]!="0000-00-00"){ | |
$("#transferDate").val(data[1]); | |
} | |
$("#bankName").val(data[2]); | |
$("#bankAccountName").val(data[3]); | |
$("#bankAccountNumber").val(data[4]); | |
$("#transferNominal").val(data[5]); | |
$("#idOrder").val(data[6]); | |
$("#statusPaymentBefore").val(data[7]); | |
}) | |
$('#confirmPacking').on('show.bs.modal', function(e) { | |
var $modal = $(this), | |
data = e.relatedTarget.id; | |
data = data.split("@"); | |
$("#idOrderPacking").val(data[0]); | |
$("#statusPackingBefore").val(data[1]); | |
}) | |
$('#confirmShipment').on('show.bs.modal', function(e) { | |
var $modal = $(this), | |
data = e.relatedTarget.id; | |
data = data.split("@"); | |
$("#deliveringStatus").prop('checked', true); | |
$("#resiNumber").prop('readonly', true); | |
$("#idOrderShipment").val(data[0]); | |
$("#shipmentBrand").val(data[1]); | |
$("#shipmentType").val(data[2]); | |
$("#shipmentPrice").val("Rp. "+data[3]); | |
}) | |
</script> | |
<script type="text/javascript"> | |
function removeChildElements(idParent){ | |
if(document.getElementById(idParent).firstChild){ | |
while(document.getElementById(idParent).firstChild){ | |
document.getElementById(idParent).removeChild(document.getElementById(idParent).firstChild); | |
} | |
} | |
} | |
function formatRupiah(input){ | |
var testString; | |
if(input.nodeName === "INPUT"){ | |
testString = input.value.substring(input.value.length-1,input.value.length); | |
}else{ | |
testString = input.innerText.substring(input.innerText.length-1,input.innerText.length); | |
} | |
var format; | |
if (!/^[0-9]+$/.test(testString)){ | |
input.value = input.value.substring(0,input.value.length-1); | |
}else{ | |
// console.log(input.value); | |
var StringWithoutCommas; | |
if(input.nodeName === "INPUT"){ | |
StringWithoutCommas = input.value.replace(/,/g, ''); | |
}else{ | |
StringWithoutCommas = input.innerText.replace(/,/g, ''); | |
} | |
// console.log(StringWithoutCommas); | |
if(StringWithoutCommas.length==4){ | |
format=StringWithoutCommas.substring(0,1)+","+StringWithoutCommas.substring(1,StringWithoutCommas.length); | |
}else if(StringWithoutCommas.length==5){ | |
format=StringWithoutCommas.substring(0,2)+","+StringWithoutCommas.substring(2,StringWithoutCommas.length); | |
}else if(StringWithoutCommas.length==6){ | |
format=StringWithoutCommas.substring(0,3)+","+StringWithoutCommas.substring(3,StringWithoutCommas.length); | |
}else if(StringWithoutCommas.length==7){ | |
format=StringWithoutCommas.substring(0,1)+","+StringWithoutCommas.substring(1,4)+","+StringWithoutCommas.substring(4,StringWithoutCommas.length); | |
}else if(StringWithoutCommas.length==8){ | |
format=StringWithoutCommas.substring(0,2)+","+StringWithoutCommas.substring(2,5)+","+StringWithoutCommas.substring(5,StringWithoutCommas.length); | |
}else if(StringWithoutCommas.length==9){ | |
format=StringWithoutCommas.substring(0,3)+","+StringWithoutCommas.substring(3,6)+","+StringWithoutCommas.substring(6,StringWithoutCommas.length); | |
}else{ | |
format = StringWithoutCommas; | |
} | |
if(input.nodeName === "INPUT"){ | |
input.value=format; | |
}else{ | |
removeChildElements(input.id); | |
input.appendChild(document.createTextNode(format)); | |
} | |
} | |
} | |
</script> | |
<script> | |
$(document).ready(function() { | |
$('#dataTables-category').DataTable({ | |
responsive: true | |
}); | |
}); | |
</script> | |
<script> | |
$(document).ready(function() { | |
$('#dataTables-customer').DataTable({ | |
"responsive": true, | |
"columnDefs": [ | |
{ | |
"targets": 2, | |
"orderable": false | |
}, | |
{ | |
"targets": 3, | |
"orderable": false | |
}, | |
{ | |
"targets": 4, | |
"orderable": false | |
}, | |
{ | |
"targets": 5, | |
"orderable": false | |
}, | |
{ | |
"targets": 6, | |
"orderable": false | |
}, | |
{ | |
"targets": 7, | |
"orderable": false | |
}, | |
{ | |
"targets": 8, | |
"orderable": false | |
} | |
] | |
}); | |
}); | |
</script> | |
<script> | |
$(document).ready(function() { | |
$('#dataTables-subcategory').DataTable({ | |
responsive: true | |
}); | |
}); | |
</script> | |
<script> | |
$(document).ready(function() { | |
$('#dataTables-choose-product').DataTable({ | |
// "responsive": true, | |
"processing": true, | |
"serverSide": true, | |
"order": [], //Initial no order. | |
// Load data for the table's content from an Ajax source | |
"ajax": { | |
"url": "<?php echo base_url() ?>/ProductController/getAllData", | |
"type": "POST" | |
}, | |
//Set column definition initialisation properties. | |
"columnDefs": [ | |
{ | |
"targets": [ 1 ], | |
"visible": false, | |
"searchable": false | |
}, | |
{ | |
"targets": [ 4 ], | |
"visible": false | |
}, | |
{ | |
"targets": [ 5 ], | |
"visible": false | |
}, | |
{ | |
"targets": [ 6 ], | |
"visible": false | |
}, | |
{ | |
"targets": 8, | |
"render": function (data,type,row){ | |
return "<button type='button' class='btn btn-primary btn-xs' onclick = 'selectProduct("+data+")'>PILIH</button>"; | |
} | |
} | |
] | |
}); | |
}); | |
</script> | |
<script> | |
$(document).ready(function() { | |
$('#dataTables-choose-suplier').DataTable({ | |
responsive: true | |
}); | |
}); | |
$(document).ready(function() { | |
$('#dataTables-order').DataTable({ | |
responsive: true | |
}); | |
}); | |
// $(document).ready(function() { | |
// $('#dataTables-product-all-backup').DataTable({ | |
// "pageLength" : 10, | |
// "processing": true, | |
// "serverSide": true, | |
// "order": [], //Initial no order. | |
// // Load data for the table's content from an Ajax source | |
// "ajax": { | |
// "url": "<?php echo base_url() ?>/ProductController/getAllData", | |
// "type": "POST" | |
// }, | |
// //Set column definition initialisation properties. | |
// "columnDefs": [ | |
// { | |
// "className": "medium-font", | |
// "targets": 1, //first column / numbering column | |
// "render": function ( data, type, row ) { | |
// data = data.split('.'); | |
// data = data[0]+"_thumb_40."+data[1]; | |
// return '<img src="<?php echo base_url(); ?>uploads/thumbnail/'+data+'" />'; | |
// } | |
// }, | |
// { | |
// "className": "medium-font", | |
// "targets": 0 | |
// }, | |
// { | |
// "className": "medium-font", | |
// "targets": 7, | |
// "orderable": false | |
// }, | |
// { | |
// "className": "medium-font", | |
// "width": "15%", | |
// "targets": 3, | |
// "render": function (data,type,row){ | |
// data = data.split("@"); | |
// return ''+data[0]+'<br>'+ | |
// '<strong>Stock : </strong>'+data[1]+' pcs<br>'+ | |
// '<form method="post" action="<?php echo site_url('ProductController/addVarian'); ?>"><input type="hidden" name="idProductVarian" value="'+data[2]+'"/><button type="submit" class="btn btn-success btn-xs">tambah varian</i></button></form>'; | |
// } | |
// }, | |
// { | |
// "className": "medium-font", | |
// "targets": 4 | |
// }, | |
// { | |
// "className": "medium-font", | |
// "targets": 6, | |
// "width": "10%", | |
// "orderable": false, | |
// "render": function (data,type,row){ | |
// return 'Rp. '+data+'<br>'; | |
// } | |
// }, | |
// { | |
// "targets": 2, | |
// "visible": false, | |
// "searchable": false | |
// }, | |
// { | |
// "targets": 1, | |
// "searchable": false, | |
// "orderable": false | |
// }, | |
// { | |
// "className": "medium-font", | |
// "targets": 5, | |
// "searchable": false, | |
// "orderable": false, | |
// "render": function (data,type,row){ | |
// return 'Rp. <strong>'+formatRupiahString(data)+'</strong><br>'; | |
// } | |
// }, | |
// { | |
// "className": "medium-font", | |
// "targets": 8, | |
// "searchable": false, | |
// "orderable": false, | |
// "width": "14%", | |
// "render": function (data,type,row){ | |
// data = data.split("@"); | |
// var price = data[0] - (data[0]*(data[1]/100)); | |
// return '<strong>Diskon : </strong>'+data[1]+'%<br>'+ | |
// '<strong>Harga : </strong>Rp. '+formatRupiahString(price); | |
// } | |
// }, | |
// { | |
// "className": "medium-font", | |
// "targets": 9, | |
// "searchable": false, | |
// "orderable": false, | |
// "width": "14%", | |
// "render": function (data,type,row){ | |
// data = data.split("@"); | |
// var price = data[0] - (data[0]*(data[1]/100)); | |
// return '<strong>Diskon : </strong>'+data[1]+'%<br>'+ | |
// '<strong>Harga : </strong>Rp. '+formatRupiahString(price); | |
// } | |
// }, | |
// { | |
// "className": "medium-font", | |
// "targets": 10, | |
// "searchable": false, | |
// "orderable": false, | |
// "width": "14%", | |
// "render": function (data,type,row){ | |
// data = data.split("@"); | |
// var price = data[0] - (data[0]*(data[1]/100)); | |
// return '<strong>Diskon : </strong>'+data[1]+'%<br>'+ | |
// '<strong>Harga : </strong>Rp. '+formatRupiahString(price); | |
// } | |
// }, | |
// { | |
// "className": "medium-font", | |
// "targets": 11, | |
// "searchable": false, | |
// "orderable": false, | |
// "render": function (data,type,row){ | |
// return "<form method='post' action='<?php echo site_url('ProductController/updatePage'); ?>'><input type='hidden' name='idProductVarian' value='"+data+"'/><button type='submit' class='btn btn-warning btn-xs'><i class='fa fa-edit'></i></button></form><br><button type='button' class='btn btn-danger btn-xs' id = '"+data+"' data-title='Delete' data-toggle='modal' data-target='#deleteProduct'><i class='fa fa-trash-o'></i></button>"; | |
// } | |
// } | |
// ], | |
// "fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) { | |
// if ( iDisplayIndex%2 ==0 ) | |
// { | |
// // $('td', nRow).css('background-color', '#f7f9f8'); | |
// $('td', nRow).addClass('warning'); | |
// } | |
// else | |
// { | |
// // $('td', nRow).css('background-color', '#cfe1aa'); | |
// $('td', nRow).addClass('info'); | |
// } | |
// } | |
// }); | |
// }); | |
$(document).ready(function() { | |
function format ( d ) { | |
// `d` is the original data object for the row | |
var element = new Array(); | |
for(var i=0; i<d.length; i++){ | |
element[i] = '<tr>'+ | |
'<td align = "center">'+d[i]['color']+'</td>'+ | |
'<td align = "center">'+d[i]['size']+'</td>'+ | |
'<td align = "center">'+d[i]['stock_awal']+' Pcs</td>'+ | |
'<td align = "center"> Rp. '+formatRupiahString(d[i]['selling_price1'])+'</td>'+ | |
'</tr>'; | |
} | |
return '<table class="table-striped table-bordered table-hover" align="center" border="1" style="padding-left:50px;">'+ | |
'<thead>'+ | |
'<tr>'+ | |
'<th>Color</th>'+ | |
'<th>Size</th>'+ | |
'<th>Stock</th>'+ | |
'<th>Price</th>'+ | |
'</tr>'+ | |
'</thead>'+ | |
'<tbody>'+ | |
element | |
'</tbody>'+ | |
'</table>'; | |
} | |
var table = $('#dataTables-product-all').DataTable({ | |
"pageLength" : 10, | |
"processing": true, | |
"serverSide": true, | |
"order": [], //Initial no order. | |
// Load data for the table's content from an Ajax source | |
"ajax": { | |
"url": "<?php echo base_url() ?>/ProductController/getAllDataProducts", | |
"type": "POST" | |
}, | |
//Set column definition initialisation properties. | |
"columnDefs": [ | |
{ | |
"className": "medium-font", | |
"width": "10%", | |
"targets": 1, //first column / numbering column | |
"render": function ( data, type, row ) { | |
data = data.split('.'); | |
data = data[0]+"_thumb_40."+data[1]; | |
var imageElement = document.createElement('img'); | |
imageElement.src = "<?php echo base_url(); ?>uploads/thumbnail/"+data; | |
// return '<img src="<?php echo base_url(); ?>uploads/thumbnail/'+data+'"/>'; | |
return '<img src="<?php echo base_url(); ?>uploads/thumbnail/'+data+'" onerror="this.onerror=null;this.src='+"'<?php echo base_url(); ?>uploads/404.png'"+';" />'; | |
} | |
}, | |
{ | |
"className": "medium-font", | |
"width": "25%", | |
"targets": 2, | |
"render": function (data,type,row){ | |
data = data.split("@"); | |
return '<form id="'+data[0]+'" method="post" action="<?php echo site_url('ProductController/OpenDetailPage'); ?>"><a href="#" onclick="document.getElementById('+data[0]+').submit();">'+data[1]+'</a><input type="hidden" name="idProduct" value="'+data[0]+'"/></form><br>'+ | |
'<form method="post" action="<?php echo site_url('ProductController/addVarian'); ?>"><input type="hidden" name="idProduct" value="'+data[0]+'"/><button type="submit" class="btn btn-success btn-xs">tambah varian</i></button></form>'; | |
} | |
}, | |
{ | |
"className": "medium-font", | |
"width": "5%", | |
"targets": 0 | |
}, | |
{ | |
"className": "medium-font", | |
"width": "10%", | |
"targets": 3, | |
"orderable": false | |
}, | |
{ | |
"className": "details-control", | |
"width": "13%", | |
"targets": 4, | |
// "render": function (data,type,row){ | |
// return "<a>"+data+"</a>"; | |
// }, | |
"orderable": false | |
}, | |
{ | |
"className": "medium-font", | |
"width": "15%", | |
"targets": 5, | |
"orderable": false | |
}, | |
{ | |
"className": "medium-font", | |
"width": "15%", | |
"targets": 6, | |
"searchable": false, | |
"orderable": false, | |
"render": function (data,type,row){ | |
return "<form method='post' action='<?php echo site_url('ProductController/updatePage'); ?>'><input type='hidden' name='idProduct' value='"+data+"'/><button type='submit' class='btn btn-warning btn-xs'><i class='fa fa-edit'></i></button></form><br><button type='button' class='btn btn-danger btn-xs' id = '"+data+"' data-title='Delete' data-toggle='modal' data-target='#deleteProduct'><i class='fa fa-trash-o'></i></button>"; | |
} | |
} | |
], | |
"fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) { | |
if ( iDisplayIndex%2 ==0 ) | |
{ | |
// $('tr', nRow).css('background-color', '#f7f9f8'); | |
$('td', nRow).addClass('warning'); | |
} | |
else | |
{ | |
// $('tr', nRow).css('background-color', '#cfe1aa'); | |
$('td', nRow).addClass('info'); | |
} | |
} | |
}); | |
$('#dataTables-product-all tbody').on('click', 'td.details-control', function () { | |
var tr = $(this).closest('tr'); | |
var row = table.row(tr); | |
var childData = row.data(); | |
if ( row.child.isShown() ) { | |
// This row is already open - close it | |
row.child.hide(); | |
tr.removeClass('shown'); | |
} | |
else { | |
// Open this row | |
row.child( format(childData[(childData.length)-1]) ).show(); | |
tr.addClass('shown'); | |
} | |
} ); | |
}); | |
$(document).ready(function() { | |
$('#dataTables-list-expenses').DataTable({ | |
"pageLength" : 10, | |
"processing": true, | |
"serverSide": true, | |
"order": [], //Initial no order. | |
// Load data for the table's content from an Ajax source | |
"ajax": { | |
"url": "<?php echo base_url() ?>/ExpenseController/getAllData", | |
"type": "POST" | |
}, | |
//Set column definition initialisation properties. | |
"columnDefs": [ | |
{ | |
"className": "medium-font", | |
"targets": 1, //first column / numbering column | |
}, | |
{ | |
"className": "medium-font", | |
"targets": 2 //first column / numbering column | |
}, | |
{ | |
"className": "medium-font", | |
"targets": 0, | |
"orderable": false | |
}, | |
{ | |
"className": "medium-font", | |
"targets": 4 | |
}, | |
{ | |
"className": "medium-font", | |
"targets": 3, | |
"width": "10%", | |
"orderable": false, | |
"render": function (data,type,row){ | |
return 'Rp. '+data+'<br>'; | |
} | |
}, | |
{ | |
"className": "medium-font", | |
"targets": 5, | |
"width": "10%", | |
"orderable": false, | |
"render": function (data,type,row){ | |
return 'Rp. '+data+'<br>'; | |
} | |
}, | |
{ | |
"className": "medium-font", | |
"targets": 6, | |
"searchable": false, | |
"orderable": false, | |
"render": function (data,type,row){ | |
return "<button type='button' class='btn btn-primary btn-xs' id = '"+data+"' data-title='Edit' data-toggle='modal' data-target='#updateExpense'>EDIT</button> | <button type='button' class='btn btn-warning btn-xs' id = '"+data+"' data-title='Delete' data-toggle='modal' data-target='#deleteExpense'>HAPUS</button>"; | |
} | |
} | |
], | |
"fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) { | |
if ( iDisplayIndex%2 ==0 ) | |
{ | |
// $('td', nRow).css('background-color', '#f7f9f8'); | |
$('td', nRow).addClass('warning'); | |
} | |
else | |
{ | |
// $('td', nRow).css('background-color', '#cfe1aa'); | |
$('td', nRow).addClass('info'); | |
} | |
} | |
}); | |
}); | |
</script> | |
<script> | |
function formatRupiahString(input){ | |
StringWithoutCommas = input.toString(); | |
// console.log(StringWithoutCommas.length); | |
// console.log(StringWithoutCommas); | |
if(StringWithoutCommas.length==4){ | |
format=StringWithoutCommas.substring(0,1)+","+StringWithoutCommas.substring(1,StringWithoutCommas.length); | |
}else if(StringWithoutCommas.length==5){ | |
format=StringWithoutCommas.substring(0,2)+","+StringWithoutCommas.substring(2,StringWithoutCommas.length); | |
}else if(StringWithoutCommas.length==6){ | |
format=StringWithoutCommas.substring(0,3)+","+StringWithoutCommas.substring(3,StringWithoutCommas.length); | |
}else if(StringWithoutCommas.length==7){ | |
format=StringWithoutCommas.substring(0,1)+","+StringWithoutCommas.substring(1,4)+","+StringWithoutCommas.substring(4,StringWithoutCommas.length); | |
}else if(StringWithoutCommas.length==8){ | |
format=StringWithoutCommas.substring(0,2)+","+StringWithoutCommas.substring(2,5)+","+StringWithoutCommas.substring(5,StringWithoutCommas.length); | |
}else if(StringWithoutCommas.length==9){ | |
format=StringWithoutCommas.substring(0,3)+","+StringWithoutCommas.substring(3,6)+","+StringWithoutCommas.substring(6,StringWithoutCommas.length); | |
}else{ | |
format = StringWithoutCommas; | |
} | |
return format; | |
} | |
$(document).ready(function() { | |
$('#city-datalist').change(function(){ | |
// console.log("ahahahah"); | |
}); | |
}); | |
</script> | |
<script type="text/javascript"> | |
function countOrderByMonth(){ | |
var dataItemSoldChart = <?php echo json_encode($dataItemSoldChart); ?>; | |
var dataChart = <?php echo json_encode($dataChart); ?>; | |
var dataDayChart = <?php echo json_encode($dataDayChart); ?>; | |
var periode = '<?php echo $periode?>'; | |
Highcharts.setOptions({ | |
lang: { | |
thousandsSep: '.' | |
} | |
}); | |
Highcharts.chart('contain', { | |
chart: { | |
type: 'column' | |
}, | |
title: { | |
text: 'GRAFIK PENJUALAN' | |
}, | |
subtitle: { | |
text: 'Periode : '+periode | |
}, | |
xAxis: { | |
categories: dataDayChart, | |
crosshair: true, | |
title: { | |
text: 'TANGGAL' | |
} | |
}, | |
yAxis: { | |
min: 0, | |
title: { | |
text: 'Jumlah(pcs)' | |
} | |
}, | |
tooltip: { | |
headerFormat: '<span style="font-size:10px">Tanggal {point.key}</span><table>', | |
pointFormat: '<tr><td style="color:{series.color};padding:0">Jumlah: </td>' + | |
'<td style="padding:0"><b>Rp. {point.y:.1f}</b></td></tr>', | |
footerFormat: '</table>', | |
shared: true, | |
useHTML: true | |
}, | |
plotOptions: { | |
column: { | |
pointPadding: 0.2, | |
borderWidth: 0 | |
} | |
}, | |
series: [{ | |
name: 'Pcs Per Tanggal', | |
data: dataItemSoldChart | |
}] | |
}); | |
} | |
if(document.getElementById('contain')!=null){ | |
countOrderByMonth(); | |
} | |
</script> | |
<script type="text/javascript"> | |
function notificationStream() { | |
var baseUrl = "<?php echo base_url() ?>"; | |
$.ajax({ | |
type:"GET", | |
url: baseUrl+"OrderController/getUnprocessedOrder", | |
dataType:"json", | |
cache:false | |
}).done(function (data) { | |
if(data.result == 200){ | |
var newUnpaidOrder = data.list5Product; | |
removeChildElements('notification-unprocessed-order'); | |
var ulElement = document.getElementById('notification-unprocessed-order'); | |
for (i = 0; i < newUnpaidOrder.length; i++) { | |
// console.log("here"); | |
var liElement = document.createElement('li'); | |
var aElement = document.createElement('a'); | |
aElement.href = "<?php echo base_url() ?>OrderController/OpenDetailPage/"+newUnpaidOrder[i]['id_order']; | |
var divSubject = document.createElement('div'); | |
divSubject.appendChild(document.createTextNode('#'+newUnpaidOrder[i]['invoice_number'])); | |
aElement.appendChild(divSubject); | |
var divUser = document.createElement('div'); | |
var usernameElement = document.createElement('i'); | |
usernameElement.className = "fa fa-user"; | |
usernameElement.appendChild(document.createTextNode(" "+newUnpaidOrder[i]['full_name'])); | |
divUser.appendChild(usernameElement); | |
var dateElement = document.createElement('span'); | |
dateElement.className = "pull-right text-muted small"; | |
var orderDate = new Date(newUnpaidOrder[i]['invoice_date']); | |
var dd = orderDate.getDate(); | |
var mm = orderDate.getMonth() + 1; //January is 0! | |
var yyyy = orderDate.getFullYear(); | |
if (dd < 10) { | |
dd = '0' + dd; | |
} | |
if (mm < 10) { | |
mm = '0' + mm; | |
} | |
dateElement.appendChild(document.createTextNode(dd+"/"+mm+"/"+yyyy)); | |
divUser.appendChild(dateElement); | |
aElement.appendChild(divUser); | |
liElement.appendChild(aElement); | |
ulElement.appendChild(liElement); | |
var dividerElement = document.createElement('li'); | |
dividerElement.className = 'divider'; | |
ulElement.appendChild(dividerElement); | |
} | |
var buttonElement = document.createElement('li'); | |
var aElement = document.createElement('a'); | |
aElement.className = "text-center"; | |
aElement.href = "<?php echo site_url('OrderController/OrderOnHold'); ?>"; | |
var textElement = document.createElement('strong'); | |
textElement.appendChild(document.createTextNode('See All Order On Hold ')); | |
aElement.appendChild(textElement); | |
var iconElement = document.createElement('i'); | |
iconElement.className = "fa fa-angle-right"; | |
aElement.appendChild(iconElement); | |
buttonElement.appendChild(aElement); | |
ulElement.appendChild(buttonElement); | |
document.getElementById('notification-number').innerHTML = data.total_data; | |
} | |
readyToFetchNotificationStream = true; | |
}); | |
} | |
function notificationPaymentStream() { | |
var baseUrl = "<?php echo base_url() ?>"; | |
$.ajax({ | |
type:"GET", | |
url: baseUrl+"OrderController/getCustomerConfirmedPayment", | |
dataType:"json", | |
cache:false | |
}).done(function (data) { | |
if(data.result == 200){ | |
var newUnpaidOrder = data.list5Product; | |
removeChildElements('notification-payment'); | |
var ulElement = document.getElementById('notification-payment'); | |
for (i = 0; i < newUnpaidOrder.length; i++) { | |
var liElement = document.createElement('li'); | |
var aElement = document.createElement('a'); | |
aElement.href = "<?php echo base_url() ?>OrderController/OpenDetailPage/"+newUnpaidOrder[i]['id_order']; | |
var divSubject = document.createElement('div'); | |
divSubject.appendChild(document.createTextNode('#'+newUnpaidOrder[i]['invoice_number'])); | |
aElement.appendChild(divSubject); | |
var divUser = document.createElement('div'); | |
var usernameElement = document.createElement('i'); | |
usernameElement.className = "fa fa-user"; | |
usernameElement.appendChild(document.createTextNode(" "+newUnpaidOrder[i]['full_name']+", telah mengkonfirmasi pembyaran !")); | |
divUser.appendChild(usernameElement); | |
var dateElement = document.createElement('span'); | |
dateElement.className = "pull-right text-muted small"; | |
var orderDate = new Date(newUnpaidOrder[i]['invoice_date']); | |
var dd = orderDate.getDate(); | |
var mm = orderDate.getMonth() + 1; //January is 0! | |
var yyyy = orderDate.getFullYear(); | |
if (dd < 10) { | |
dd = '0' + dd; | |
} | |
if (mm < 10) { | |
mm = '0' + mm; | |
} | |
dateElement.appendChild(document.createTextNode(dd+"/"+mm+"/"+yyyy)); | |
divUser.appendChild(dateElement); | |
aElement.appendChild(divUser); | |
liElement.appendChild(aElement); | |
ulElement.appendChild(liElement); | |
var dividerElement = document.createElement('li'); | |
dividerElement.className = 'divider'; | |
ulElement.appendChild(dividerElement); | |
} | |
var buttonElement = document.createElement('li'); | |
var aElement = document.createElement('a'); | |
aElement.className = "text-center"; | |
aElement.href = "<?php echo site_url('OrderController/OrderOnWaiting'); ?>"; | |
var textElement = document.createElement('strong'); | |
textElement.appendChild(document.createTextNode('See All Order Waiting For Approval ')); | |
aElement.appendChild(textElement); | |
var iconElement = document.createElement('i'); | |
iconElement.className = "fa fa-angle-right"; | |
aElement.appendChild(iconElement); | |
buttonElement.appendChild(aElement); | |
ulElement.appendChild(buttonElement); | |
document.getElementById('notification-number-payment').innerHTML = data.total_data; | |
}else{ | |
} | |
}); | |
} | |
function notificationEmailStream() { | |
var baseUrl = "<?php echo base_url() ?>"; | |
$.ajax({ | |
type:"GET", | |
url: baseUrl+"MailController/getNewEmail", | |
dataType:"json", | |
cache:false | |
}).done(function (data) { | |
if(data.result == 200){ | |
var newMail = data.list5NewEmail; | |
removeChildElements('notification-email'); | |
var ulElement = document.getElementById('notification-email'); | |
for (i = 0; i < newMail.length; i++) { | |
var liElement = document.createElement('li'); | |
var aElement = document.createElement('a'); | |
aElement.href = "<?php echo base_url() ?>MailController/reply/"+newMail[i]['id_mail_in']; | |
var divSubject = document.createElement('div'); | |
divSubject.appendChild(document.createTextNode('Subject : '+newMail[i]['about'])); | |
aElement.appendChild(divSubject); | |
var divUser = document.createElement('div'); | |
var usernameElement = document.createElement('i'); | |
usernameElement.className = "fa fa-user"; | |
usernameElement.appendChild(document.createTextNode(" "+newMail[i]['name'])); | |
divUser.appendChild(usernameElement); | |
var dateElement = document.createElement('span'); | |
dateElement.className = "pull-right text-muted small"; | |
var emailDate = new Date(newMail[i]['created_at']); | |
var dd = emailDate.getDate(); | |
var mm = emailDate.getMonth() + 1; //January is 0! | |
var yyyy = emailDate.getFullYear(); | |
if (dd < 10) { | |
dd = '0' + dd; | |
} | |
if (mm < 10) { | |
mm = '0' + mm; | |
} | |
dateElement.appendChild(document.createTextNode(dd+"/"+mm+"/"+yyyy)); | |
divUser.appendChild(dateElement); | |
aElement.appendChild(divUser); | |
liElement.appendChild(aElement); | |
ulElement.appendChild(liElement); | |
var dividerElement = document.createElement('li'); | |
dividerElement.className = 'divider'; | |
ulElement.appendChild(dividerElement); | |
} | |
var buttonElement = document.createElement('li'); | |
var aElement = document.createElement('a'); | |
aElement.className = "text-center"; | |
aElement.href = "<?php echo site_url('MailController'); ?>"; | |
var textElement = document.createElement('strong'); | |
textElement.appendChild(document.createTextNode('See All New Mail ')); | |
aElement.appendChild(textElement); | |
var iconElement = document.createElement('i'); | |
iconElement.className = "fa fa-angle-right"; | |
aElement.appendChild(iconElement); | |
buttonElement.appendChild(aElement); | |
ulElement.appendChild(buttonElement); | |
document.getElementById('notification-mail-number').innerHTML = data.total_data; | |
} | |
}); | |
} | |
const readyToFetchNotificationStream = true; | |
$(document).ready(function () { | |
window.setInterval(function () { | |
if (readyToFetchNotificationStream) { | |
readyToFetchNotificationStream = false; | |
notificationStream(); | |
} | |
}, 5000); | |
}); | |
$(document).ready(function () { | |
window.setInterval(function () { | |
notificationPaymentStream(); | |
}, 7000); | |
}); | |
$(document).ready(function () { | |
window.setInterval(function () { | |
notificationEmailStream(); | |
}, 2000); | |
}); | |
</script> | |
<script type="text/javascript"> | |
//Autocomplete for product receiver | |
function autocompleteCity(inp, arr) { | |
/*the autocomplete function takes two arguments, | |
the text field element and an array of possible autocompleted values:*/ | |
var currentFocus; | |
/*execute a function when someone writes in the text field:*/ | |
inp.addEventListener("input", function(e) { | |
var a, b, i, val = this.value; | |
/*close any already open lists of autocompleted values*/ | |
closeAllLists(); | |
if (!val) { return false;} | |
currentFocus = -1; | |
/*create a DIV element that will contain the items (values):*/ | |
a = document.createElement("DIV"); | |
a.setAttribute("id", this.id + "autocomplete-list"); | |
a.setAttribute("class", "autocomplete-items"); | |
/*append the DIV element as a child of the autocomplete container:*/ | |
this.parentNode.appendChild(a); | |
/*for each item in the array...*/ | |
for (i = 0; i < arr.length; i++) { | |
/*check if the item starts with the same letters as the text field value:*/ | |
var city = arr[i]['type']+" "+arr[i]['city_name']; | |
city = city.toUpperCase(); | |
// if (city.substr(0, val.length).toUpperCase() == val.toUpperCase()) { | |
var indexFound = city.indexOf(val.toUpperCase()) ; | |
if (indexFound >= 0) { | |
/*create a DIV element for each matching element:*/ | |
b = document.createElement("DIV"); | |
/*make the matching letters bold:*/ | |
b.innerHTML = city.substr(0,indexFound)+"<strong>" + city.substr(city.indexOf(val.toUpperCase()), val.length) + "</strong>"+city.substr((indexFound+val.length), city.length); | |
// b.innerHTML += city.substr(val.length); | |
/*insert a input field that will hold the current array item's value:*/ | |
b.innerHTML += "<input type='hidden' value='" + city + "'>"; | |
b.innerHTML += "<input type='hidden' value='" + arr[i]['city_id'] + "'>"; | |
/*execute a function when someone clicks on the item value (DIV element):*/ | |
b.addEventListener("click", function(e) { | |
/*insert the value for the autocomplete text field:*/ | |
inp.value = this.getElementsByTagName("input")[0].value; | |
showDistricts(this.getElementsByTagName("input")[1].value); | |
/*close the list of autocompleted values, | |
(or any other open lists of autocompleted values:*/ | |
closeAllLists(); | |
}); | |
a.appendChild(b); | |
} | |
} | |
}); | |
/*execute a function presses a key on the keyboard:*/ | |
inp.addEventListener("keydown", function(e) { | |
var x = document.getElementById(this.id + "autocomplete-list"); | |
if (x) x = x.getElementsByTagName("div"); | |
if (e.keyCode == 40) { | |
/*If the arrow DOWN key is pressed, | |
increase the currentFocus variable:*/ | |
currentFocus++; | |
/*and and make the current item more visible:*/ | |
addActive(x); | |
} else if (e.keyCode == 38) { //up | |
/*If the arrow UP key is pressed, | |
decrease the currentFocus variable:*/ | |
currentFocus--; | |
/*and and make the current item more visible:*/ | |
addActive(x); | |
} else if (e.keyCode == 13) { | |
/*If the ENTER key is pressed, prevent the form from being submitted,*/ | |
e.preventDefault(); | |
if (currentFocus > -1) { | |
/*and simulate a click on the "active" item:*/ | |
if (x) x[currentFocus].click(); | |
} | |
} | |
}); | |
function addActive(x) { | |
/*a function to classify an item as "active":*/ | |
if (!x) return false; | |
/*start by removing the "active" class on all items:*/ | |
removeActive(x); | |
if (currentFocus >= x.length) currentFocus = 0; | |
if (currentFocus < 0) currentFocus = (x.length - 1); | |
/*add class "autocomplete-active":*/ | |
x[currentFocus].classList.add("autocomplete-active"); | |
} | |
function removeActive(x) { | |
/*a function to remove the "active" class from all autocomplete items:*/ | |
for (var i = 0; i < x.length; i++) { | |
x[i].classList.remove("autocomplete-active"); | |
} | |
} | |
function closeAllLists(elmnt) { | |
/*close all autocomplete lists in the document, | |
except the one passed as an argument:*/ | |
var x = document.getElementsByClassName("autocomplete-items"); | |
for (var i = 0; i < x.length; i++) { | |
if (elmnt != x[i] && elmnt != inp) { | |
x[i].parentNode.removeChild(x[i]); | |
} | |
} | |
} | |
/*execute a function when someone clicks in the document:*/ | |
document.addEventListener("click", function (e) { | |
closeAllLists(e.target); | |
}); | |
} | |
if(document.getElementById('city')!=null){ | |
//Get City Data | |
var baseUrl = "<?php echo base_url() ?>"; | |
$.ajax({ | |
type:"GET", | |
url: baseUrl+"OrderController/getCities", | |
dataType:"json", | |
cache:false, | |
success: function(data){ | |
if(data.result== 200){ | |
var result = JSON.parse(data.listCities); | |
if(result.rajaongkir.status.code == 200){ | |
var cities = result.rajaongkir.results; | |
autocompleteCity(document.getElementById("city"), cities); | |
}else{ | |
var errorMessage = document.getElementById('error-message'); | |
removeChildElements('error-message'); | |
errorMessage.appendChild(document.createTextNode('Gagal Menerima Data Kota')); | |
$('#errorMessage').modal('show'); | |
} | |
}else{ | |
var errorMessage = document.getElementById('error-message'); | |
removeChildElements('error-message'); | |
errorMessage.appendChild(document.createTextNode('Gagal Menerima Data Kota : '+data.error)); | |
$('#errorMessage').modal('show'); | |
} | |
}, | |
error: function(xhr, status, error) { | |
var errorMessage = document.getElementById('error-message'); | |
removeChildElements('error-message'); | |
errorMessage.appendChild(document.createTextNode('Gagal Menerima Data Kota : '+error)); | |
$('#errorMessage').modal('show'); | |
} | |
}); | |
} | |
</script> | |
<script type="text/javascript"> | |
$(document).ready(function() { | |
$('.datepicker').datepicker({ | |
todayBtn: "linked", | |
keyboardNavigation: false, | |
todayHighlight :true, | |
forceParse: false, | |
calendarWeeks: true, | |
autoclose: true, | |
format: 'dd-M-yyyy' | |
}); | |
$('#datePurchase').datepicker().datepicker("setDate", new Date()); | |
}) | |
</script> | |
<script> | |
url = "<?php echo base_url() ?>"; | |
$(document).ready(function() { | |
$('#supplier1').select2(); | |
$("#supplier1").on("change", function(){ | |
var v = $(this).val(); | |
var baseUrl = '<?php echo base_url(); ?>PurchaseStockController/autocomplete_supplier/'+v; | |
$.ajax({ | |
url: baseUrl, | |
dataType: 'json', | |
success: function(datas){ | |
console.log(datas); | |
$('#supplier').val(datas.id_suplier); | |
}, | |
error: function (xhr, ajaxOptions, thrownError) { | |
alert("Ups Ada sedikit kesalahan.. Segera Hubungi Administrator "); | |
} | |
}); | |
}); | |
}); | |
$(document).ready(function() { | |
$('#updateDistributor').select2(); | |
$("#updateDistributor").on("change", function(){ | |
var v = $(this).val(); | |
v = data.split("-"); | |
var baseUrl = '<?php echo base_url(); ?>PurchaseStockController/autocomplete_supplier/'+v[0]; | |
$.ajax({ | |
url: baseUrl, | |
dataType: 'json', | |
success: function(datas){ | |
// console.log(datas); | |
$('#updateDistributor').val(datas.id_suplier+"-"+v[1]); | |
}, | |
error: function (xhr, ajaxOptions, thrownError) { | |
alert("Ups Ada sedikit kesalahan.. Segera Hubungi Administrator "); | |
} | |
}); | |
}); | |
}); | |
</script> | |
<script type="text/javascript"> | |
var detailFieldRepeater = new FieldRepeater("#templateDetailPurchase", "#detailPurchaseContainer", { | |
}); | |
// get current selected nama barang | |
function getSelectedDetailId() { | |
var ret = []; | |
var res = $("#detailPurchaseContainer input[type=hidden][name*='id_product_varian']"); | |
$.each(res, function(i, item) { | |
ret.push($(item).val()); | |
}); | |
return ret; | |
} | |
function onDetailFieldRepeaterAdd(self, elem) { | |
var index = Math.random(); | |
$(elem).attr("data-index", index); | |
} | |
$(document).ready(function() { | |
detailFieldRepeater.init(onDetailFieldRepeaterAdd); | |
$('.form-addable').on('click', function(e) { | |
e.preventDefault(); | |
detailFieldRepeater.add(false, onDetailFieldRepeaterAdd); | |
}); | |
$('.form-removable').on('click', function(e) { | |
e.preventDefault(); | |
var index = $(this).parents(".form-group").attr("data-index"); | |
detailFieldRepeater.remove(this); | |
}); | |
}); | |
function myTypeHead(obj){ | |
$(obj).typeahead({ | |
source: function(query, process) { | |
var selectedDetailId = getSelectedDetailId(); | |
var res = []; | |
return $.get('<?php echo base_url(); ?>PurchaseStockController/autocomplete', { query: query }, function (data) { | |
$.each(JSON.parse(data), function(i, item) { | |
if (selectedDetailId.indexOf(item.id_product_varian) === -1) { | |
item.product_name; | |
res.push(item); | |
} | |
}); | |
process(res); | |
}) | |
}, | |
updater: function(item) { | |
var elem = $(this)[0].$element.siblings("input[type=hidden][name*='id_product_varian']")[0]; | |
$(elem).val(item.id_product_varian); | |
return item.product_name; | |
}, | |
displayText: function(item) { | |
return item.product_name; | |
}, | |
}); | |
} | |
</script> | |
<script type="text/javascript"> | |
url = "<?php echo base_url() ?>"; | |
function check_invoice() { | |
invoice_conflict = $("#invoicePurchase").val(); | |
$.ajax({ | |
url : url + "PurchaseStockController/invoiceConflicted", | |
data : {invoice_conflict : invoice_conflict}, | |
type : "post", | |
dataType: 'json', | |
success: function(hasil){ | |
var result = hasil.list; | |
if (result) { | |
$("#warning_invoice").html("<p style='color:red; font-size: 11px'> Nomor invoice sudah ada, Harap ganti dengan nomor invoice yang lain. </p>"); | |
$("#button-submit").attr('disabled', 'disabled'); | |
}else{ | |
$("#warning_invoice").html(""); | |
$("#button-submit").prop("disabled", false); | |
} | |
}, | |
error : function (e) { | |
alert(e); | |
console.log(e); | |
} | |
}) | |
}; | |
</script> | |
<script type="text/javascript"> | |
function check_percent() { | |
discount_store = $("#discountStore1").val(); | |
type_discount = $("#typeDiscountStore1").val(); | |
if (discount_store != '' && type_discount == '') { | |
alert('Tipe diskon tidak boleh kosong'); | |
$("#discountStore1").val(''); | |
$("#typeDiscountStore1").val(''); | |
} | |
if (type_discount == 2 && discount_store > 100) { | |
alert('Diskon tipe persen tidak boleh lebih dari 100%'); | |
$("#discountStore1").val(''); | |
$("#typeDiscountStore1").val(''); | |
} | |
countTotalPrice(); | |
} | |
function check_discount(self) { | |
var isi = $(self).val(); | |
//get parent index | |
var parent = $(self).parents(".form-group"); | |
var index = parent.attr("data-index"); | |
var element = $("[data-index = '"+index+"']"); | |
var field1 = $(element).find("[id='typeDiscountPcs1']").val(); | |
if (isi != '' && field1 == '') { | |
alert('Tipe diskon tidak boleh kosong'); | |
$(element).find("[id='discountProduct1']").val(''); | |
$(element).find("[id='typeDiscountPcs1']").val(''); | |
} | |
if (field1 == 2 && isi > 100) { | |
alert('Diskon tipe persen tidak boleh lebih dari 100%'); | |
$(element).find("[id='discountProduct1']").val(''); | |
$(element).find("[id='typeDiscountPcs1']").val(''); | |
} | |
var price = $(element).find("[id='priceProduct1']").val(); | |
var qty = $(element).find("[id='qtyPurchase1']").val(); | |
var discount_select = $(element).find("[id='typeDiscountPcs1']").val(); | |
var discount = $(element).find("[id='discountProduct1']").val(); | |
// alert(isi); | |
if (price == '' && qty == '' && isi != '' && discount == '') { | |
$(element).find("[id='price_diskon1']").val(''); | |
} | |
if (price != '' && qty == '' && isi != '' && discount == '') { | |
$(element).find("[id='price_diskon1']").val(''); | |
} | |
if (price == '' && qty != '' && isi != '' && discount == '') { | |
$(element).find("[id='price_diskon1']").val(''); | |
} | |
if (price == '' && qty == '' && isi != '' && discount != '') { | |
$(element).find("[id='price_diskon1']").val(''); | |
} | |
if (price == '' && qty == '' && isi == '' && discount != '') { | |
$(element).find("[id='price_diskon1']").val(''); | |
} | |
if (price == '' && qty != '' && isi == '' && discount != '') { | |
$(element).find("[id='price_diskon1']").val(''); | |
} | |
if (price != '' && qty == '' && isi == '' && discount != '') { | |
$(element).find("[id='price_diskon1']").val(''); | |
} | |
if (price != '' && qty != '' && isi != '' && discount != '') { | |
if (discount_select == 1) { | |
var diskon = (price * qty) - discount; | |
$(element).find("[id='price_diskon1']").val(diskon); | |
} | |
if (discount_select == 2) { | |
var cek_diskon = price * qty * discount/100; | |
var diskon = (price * qty) - cek_diskon; | |
$(element).find("[id='price_diskon1']").val(diskon); | |
} | |
} | |
countTotalPrice(); | |
} | |
function disc_after_discount(self) { | |
var isi = $(self).val(); | |
//get parent index | |
var parent = $(self).parents(".form-group"); | |
var index = parent.attr("data-index"); | |
var element = $("[data-index = '"+index+"']"); | |
var price = $(element).find("[id='priceProduct1']").val(); | |
var qty = $(element).find("[id='qtyPurchase1']").val(); | |
var discount_select = $(element).find("[id='typeDiscountPcs1']").val(); | |
var discount = $(element).find("[id='discountProduct1']").val(); | |
if (qty == '' && discount_select == '' && discount == '') { | |
$(element).find("[id='price_diskon1']").val(price); | |
} | |
if (price != '' && qty != '' && discount_select == '' && discount == '') { | |
var diskon = price * qty; | |
$(element).find("[id='price_diskon1']").val(diskon); | |
} | |
if (price == '' && qty != '' && discount_select == '' && discount == '') { | |
$(element).find("[id='price_diskon1']").val(''); | |
} | |
countTotalPrice(); | |
} | |
function countTotalPrice(){ | |
var totalPrice = document.getElementsByName('price_diskon[]'); | |
var subTotalPrice = document.getElementById('subTotalPrice'); | |
var count = 0; | |
for(var i=0; i<totalPrice.length; i++){ | |
if(totalPrice[i].value != ''){ | |
count = count + parseInt(totalPrice[i].value); | |
} | |
} | |
var discountStore = document.getElementById('discountStore1'); | |
var discountStoreType = document.getElementById('typeDiscountStore1'); | |
var shippingPriceField = document.getElementById('shippingPurchase'); | |
var countDiscountStore = 0; | |
if(discountStore.value != ''){ | |
// console.log(discountStoreType.value); | |
if(discountStoreType.value == '1'){ | |
count = count - parseInt(discountStore.value); | |
}else{ | |
// console.log(count * (parseInt(discountStore.value)/100)); | |
count = count - (count * (parseInt(discountStore.value)/100)); | |
} | |
} | |
if(shippingPriceField.value != ''){ | |
count = count + parseInt(shippingPriceField.value); | |
} | |
subTotalPrice.value = count; | |
} | |
</script> | |
<script type="text/javascript"> | |
var link_base = "<?php echo base_url(); ?>"; | |
function btn_delete(id) { | |
// alert(id); | |
$.ajax({ | |
type: 'GET', | |
url: link_base+'/PurchaseStockController/delete_modal/'+ id, | |
// data: {id : id}, | |
success: function (data) { | |
// console.log(data); | |
document.getElementById("modaldelete").action = link_base+'/PurchaseStockController/delete/'+id; | |
} | |
}) | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment