

function post(path, params, target, method) {
    method = method || "post"; // Set method to post by default if not specified.
	target = target || "_blank";//open new tab
	
    // The rest of this code assumes you are not using a library.
    // It can be made less wordy if you use one.
    var form = document.createElement("form");
    form.setAttribute("method", method);
    form.setAttribute("action", path);
    form.setAttribute("target", target);

    for(var key in params) {
        if(params.hasOwnProperty(key)) {
			if(typeof params[key] === 'object')
			{
				var childObj = params[key];
				for(var key2 in childObj)
				{
					if(typeof childObj[key2] === 'object')
					{
						var childObj2 = childObj[key2];
						for(var key3 in childObj2)
						{
							if(typeof childObj2[key3] === 'object')
							{
								var childObj3 = childObj2[key3];
								for(var key4 in childObj3)
								{
									if(typeof childObj3[key4] === 'object')
									{
										//console.log("key4 : " + key4 + " is object!!!");
									}
									else
									{
										var myName = key + '[' + key2 + ']' +  '[' + key3 + ']' +  '[' + key4 + ']';
										var myValue = childObj3[key4];
										setInput(form, myName, myValue);
									}
								}
							}
							else
							{
								var myName = key + '[' + key2 + ']' +  '[' + key3 + ']';
								var myValue = childObj2[key3];
								setInput(form, myName, myValue);
							}
						}
					}
					else
					{
						var myName = key + '[' + key2 + ']';
						var myValue = childObj[key2];
						setInput(form, myName, myValue);
					}
				}
			}
			else
			{
				setInput(form, key, params[key]);
			}
            
         }
    }

    document.body.appendChild(form);
    form.submit();
}

function setInput(form, key, value)
{
	var hiddenField = document.createElement("input");
	hiddenField.setAttribute("type", "hidden");
	hiddenField.setAttribute("name", key);
	hiddenField.setAttribute("value", value);
	form.appendChild(hiddenField);
}

//type so far : tb, dd, num, kp, pwd, amount, kplama
function checkInput(inputList)
{
	var inputIncorrect = false;
	for	(var index = 0; index < inputList.length; index++) 
	{
		inputIncorrect = false;
		var myInput = $("#" + inputList[index][0]);
		var myInput_label = $("#" + inputList[index][0] + "_label");
		myInput_label.css("color", "black");
		//alert("checkInput " + inputList[index][0] + " = " + inputList[index][2]);
		if(inputList[index][2] == 'tb')
		{
			/*
			console.log(myInput.val().length);
			console.log(myInput.attr('minLength')!= undefined);
			console.log(myInput.attr('minLength'));
			console.log(myInput.attr('maxLength')!= undefined);
			console.log(myInput.attr('maxLength'));
			*/
			if (myInput.val() == "")
			{
				swal.fire({
					text: "Sila masukkan " + inputList[index][1],
					icon: "error",
					buttonsStyling: false,
					confirmButtonText: "OK!",
					customClass: {
						confirmButton: "btn font-weight-bold btn-light-primary"
					}
				}).then(function() {
					myInput_label.css("color", "red");
					myInput.focus();
				});
				return false;
			}
			else if (myInput.attr('minLength') != undefined && myInput.val().length < myInput.attr('minLength'))
			{
				swal.fire({
					text: "Sila masukkan minima " + myInput.attr('minLength') + " angka/huruf untuk " + inputList[index][1],
					icon: "error",
					buttonsStyling: false,
					confirmButtonText: "OK!",
					customClass: {
						confirmButton: "btn font-weight-bold btn-light-primary"
					}
				}).then(function() {
					myInput_label.css("color", "red");
					myInput.focus();
				});
				return false;
			}
			else if (myInput.attr('maxLength') != undefined && myInput.val().length > myInput.attr('maxLength'))
			{
				swal.fire({
					text: "Hanya maksima "  + myInput.attr('minLength') + " angka/huruf dibenarkan untuk " + inputList[index][1],
					icon: "error",
					buttonsStyling: false,
					confirmButtonText: "OK!",
					customClass: {
						confirmButton: "btn font-weight-bold btn-light-primary"
					}
				}).then(function() {
					myInput_label.css("color", "red");
					myInput.focus();
				});
				return false;
			}
			else
			{
				myInput_label.css("color", "black");
			}
		}
		else if(inputList[index][2] == 'tinymce')
		{
			var editorContent = tinymce.get(inputList[index][0]).getContent();
			if (editorContent == "")
			{
				swal.fire({
					text: "Sila masukkan " + inputList[index][1],
					icon: "error",
					buttonsStyling: false,
					confirmButtonText: "OK!",
					customClass: {
						confirmButton: "btn font-weight-bold btn-light-primary"
					}
				}).then(function() {
					myInput_label.css("color", "red");
					myInput.focus();
				});
				return false;
			}
			else
			{
				myInput_label.css("color", "black");
			}
		}
		else if(inputList[index][2] == 'amount')
		{
			if (myInput.val() == "" || Number(myInput.val()) <= 0)
			{
				swal.fire({
					text: "Sila masukkan " + inputList[index][1],
					icon: "error",
					buttonsStyling: false,
					confirmButtonText: "OK!",
					customClass: {
						confirmButton: "btn font-weight-bold btn-light-primary"
					}
				}).then(function() {
					myInput_label.css("color", "red");
					myInput.focus();
				});
				return false;
			}
			else
			{
				myInput_label.css("color", "black");
			}
		}
		else if(inputList[index][2] == 'dd')
		{
			if (myInput.val() == 0 || myInput.val() === null)
			{
				swal.fire({
					text: "Sila Pilih " + inputList[index][1],
					icon: "error",
					buttonsStyling: false,
					confirmButtonText: "OK!",
					customClass: {
						confirmButton: "btn font-weight-bold btn-light-primary"
					}
				}).then(function() {
					myInput_label.css("color", "red");
					myInput.focus();
				});
				return false;
			}
			else
			{
				myInput_label.css("color", "black");
			}
		}
		else if(inputList[index][2] == 'num')
		{
			if (myInput.val() == "")
			{
				swal.fire({
					text: "Sila Masukkan " + inputList[index][1],
					icon: "error",
					buttonsStyling: false,
					confirmButtonText: "OK!",
					customClass: {
						confirmButton: "btn font-weight-bold btn-light-primary"
					}
				}).then(function() {
					myInput_label.css("color", "red");
					myInput.focus();
				});
				return false;
			}
			else if(isNaN(myInput.val())) //Check whether a number is an illegal number:
			{
				swal.fire({
					text: "Sila masukkan nombor sahaja untuk " + inputList[index][1],
					icon: "error",
					buttonsStyling: false,
					confirmButtonText: "OK!",
					customClass: {
						confirmButton: "btn font-weight-bold btn-light-primary"
					}
				}).then(function() {
					myInput_label.css("color", "red");
					myInput.focus();
				});
				return false;
			}
			else
			{
				myInput_label.css("color", "black");
			}
		}
		else if(inputList[index][2] == 'kp')
		{
			if (isNaN(myInput.val()) || myInput.val().length < 12 || !checkValidKP(myInput.val()))
			{
				swal.fire({
					text: "Sila masukkan " + inputList[index][1] + " dalam format yang betul.\nContoh: 801021045383",
					icon: "error",
					buttonsStyling: false,
					confirmButtonText: "OK!",
					customClass: {
						confirmButton: "btn font-weight-bold btn-light-primary"
					}
				}).then(function() {
					myInput_label.css("color", "red");
					myInput.focus();
				});
				return false;
			}
			else
			{
				myInput_label.css("color", "black");
			}
		}
		else if(inputList[index][2] == 'kp_ae')
		{
			var kpinfo = processKP(myInput.val());
			var a = moment();
			var b = moment(kpinfo[0], 'DD-MM-YYYY');
			var age = a.diff(b, 'years');
			var maxAge = 2;//change here ifneeded
			if(age > maxAge)
			{
				swal.fire({
					text: "Program cuma terbuka kepada umur bawah " + maxAge + " tahun sahaja",
					icon: "error",
					buttonsStyling: false,
					confirmButtonText: "OK!",
					customClass: {
						confirmButton: "btn font-weight-bold btn-light-primary"
					}
				}).then(function() {
					myInput_label.css("color", "red");
					myInput.focus();
				});
				return false;
			}
			else if (isNaN(myInput.val()) || myInput.val().length < 12 || !checkValidKP(myInput.val()))
			{
				swal.fire({
					text: "Sila masukkan " + inputList[index][1] + " dalam format yang betul.\nContoh: 801021045383",
					icon: "error",
					buttonsStyling: false,
					confirmButtonText: "OK!",
					customClass: {
						confirmButton: "btn font-weight-bold btn-light-primary"
					}
				}).then(function() {
					myInput_label.css("color", "red");
					myInput.focus();
				});
				return false;
			}
			else
			{
				myInput_label.css("color", "black");
			}
		}
		else if(inputList[index][2] == 'kp_waris')
		{
			var kpinfo = processKP(myInput.val());
			var a = moment();
			var b = moment(kpinfo[0], 'DD-MM-YYYY');
			var age = a.diff(b, 'years');
			var minAge = 18;//change here ifneeded
			if(age < minAge)
			{
				swal.fire({
					text: "Waris hendaklah warganegara yang berumur " + minAge + " tahun dan ke atas",
					icon: "error",
					buttonsStyling: false,
					confirmButtonText: "OK!",
					customClass: {
						confirmButton: "btn font-weight-bold btn-light-primary"
					}
				}).then(function() {
					myInput_label.css("color", "red");
					myInput.focus();
				});
				return false;
			}
			else if (isNaN(myInput.val()) || myInput.val().length < 12 || !checkValidKP(myInput.val()))
			{
				swal.fire({
					text: "Sila masukkan " + inputList[index][1] + " dalam format yang betul.\nContoh: 801021045383",
					icon: "error",
					buttonsStyling: false,
					confirmButtonText: "OK!",
					customClass: {
						confirmButton: "btn font-weight-bold btn-light-primary"
					}
				}).then(function() {
					myInput_label.css("color", "red");
					myInput.focus();
				});
				return false;
			}
			else
			{
				myInput_label.css("color", "black");
			}
		}
		else if(inputList[index][2] == 'pwd')
		{
			var checkResult = checkPassword(myInput.val());
			if(!checkResult.valid)
			{
				swal.fire({
					text: checkResult.message,
					icon: "error",
					buttonsStyling: false,
					confirmButtonText: "OK!",
					customClass: {
						confirmButton: "btn font-weight-bold btn-light-primary"
					}
				}).then(function() {
					myInput_label.css("color", "red");
					myInput.focus();
				});
				return false;
			}
			else
			{
				myInput_label.css("color", "black");
			}
		}
		else if(inputList[index][2] == 'nm')
		{
			var checkResult = checkName(myInput.val());
			if(!checkResult.valid)
			{
				swal.fire({
					text: checkResult.message,
					icon: "error",
					buttonsStyling: false,
					confirmButtonText: "OK!",
					customClass: {
						confirmButton: "btn font-weight-bold btn-light-primary"
					}
				}).then(function() {
					myInput_label.css("color", "red");
					myInput.focus();
				});
				return false;
			}
			else
			{
				myInput_label.css("color", "black");
			}
		}
		else if(inputList[index][2] == 'em')
		{
			var checkResult = checkEmail(myInput.val());
			if(!checkResult.valid)
			{
				swal.fire({
					text: checkResult.message,
					icon: "error",
					buttonsStyling: false,
					confirmButtonText: "OK!",
					customClass: {
						confirmButton: "btn font-weight-bold btn-light-primary"
					}
				}).then(function() {
					myInput_label.css("color", "red");
					myInput.focus();
				});
				return false;
			}
			else
			{
				myInput_label.css("color", "black");
			}
		}
		else if(inputList[index][2] == 'kplama')
		{
			if (myInput.val() == "")
			{
				swal.fire({
					text: "Sila masukkan " + inputList[index][1],
					icon: "error",
					buttonsStyling: false,
					confirmButtonText: "OK!",
					customClass: {
						confirmButton: "btn font-weight-bold btn-light-primary"
					}
				}).then(function() {
					myInput_label.css("color", "red");
					myInput.focus();
				});
				return false;
			}
			else if (myInput.val().search(/\d/) == -1)
			{
				swal.fire({
					text: "Format KP Lama tidak tepat. KP Lama hendaklah mengandungi nombor & huruf atau nombor sahaja. Tinggalkan kosong sekiranya tiada maklumat",
					icon: "error",
					buttonsStyling: false,
					confirmButtonText: "OK!",
					customClass: {
						confirmButton: "btn font-weight-bold btn-light-primary"
					}
				}).then(function() {
					myInput_label.css("color", "red");
					myInput.focus();
				});
				return false;
			}
			else
			{
				myInput_label.css("color", "black");
			}
		}
	}
	return true;
}

function checkValidKP(kp_baru, maxAge=0)
{
	var result = false;
	if(kp_baru.length == 12)
	{
		var datenow = moment();
		var year = kp_baru.substring(0, 2);
		year = ((year <= datenow.format('YY'))?'20':'19'); //if less than 15, means 20xx, else 19xx
		var birthdate = moment(year + kp_baru, "YYYYMMDD");
		if(maxAge > 0)
			return (!isNaN(birthdate))&&((datenow.format('YY') - year) <= maxAge);
		else
		return (!isNaN(birthdate)); //return birthdate is valid
	}
	return result;
}

function processKP(kp_baru)
{
	var result = [];
	if(kp_baru.length == 12)
	{
		var datenow = moment();
		var year = kp_baru.substring(0, 2);
		year = ((year <= datenow.format('YY'))?'20':'19') + year;
		var month = kp_baru.substring(2, 4);
		var day = kp_baru.substring(4, 6);
		var state = kp_baru.substring(6, 8);
		var gender = kp_baru.substring(11, 12);
		//result.push(((year < 15)?'20':'19') + year); //if less than 15, means 20xx, else 19xx
		//result.push(Number(month));
		//result.push(Number(date));
		
		var birthdate = moment(year + month + day, "YYYYMMDD");
		result.push(birthdate.format('DD-MM-YYYY')); //even is female, odd is male
		//result.push((state == '08' || state == '37' || state == '38' || state == '39')?1:2); //08, 37, 38, 39 penang kod
		result.push((gender % 2 == 0)?2:1); //even is female, odd is male
		result.push((datenow.format('YYYY') - year)); //age
	}
	return result;
}

function checkPassword(pwd) {
	var result = [];
	result.valid = false;
    if (pwd.length < 8) {
        result.message = ("Password too short. Need at least 8 character");
    } else if (pwd.length > 20) {
        result.message = ("Password too short. Maximum 20 character");
    } else if (pwd.search(/\d/) == -1) {
        result.message = ("Password must contain number");
    } else if (pwd.search(/[a-zA-Z]/) == -1) {
        result.message = ("Password must contain alphabet");
    }else if (pwd.search(/[\!\@\#\$\_\*]/) == -1) {
        result.message = ("Password must contain symbol. \nAllowed symbol are !@#$_* ");
    } else if (pwd.search(/[^a-zA-Z0-9\!\@\#\$\_\*]/) != -1) {
        result.message = ("Password must contain only allowed symbol. \nAllowed symbol are !@#$_* ");
    }
	else{
		result.valid = true;
	}
    return result;
}

function checkEmail(em) {
	var re = /\S+@\S+\.\S+/;
	var result = [];
	result.valid = false;
    if (em.length < 5) {
        result.message = ("Sila masukkan email");
    } else if (!re.test(em)) {
        result.message = ("Format email tidak tepat.");
    }
	else{
		result.valid = true;
	}
    return result;
}

function checkName(nm) {
	var pattern = /^[a-zA-Z\s\'\`\-\@\.\/]+$/g;
	var result = [];
	result.valid = false;
    if (nm.length < 5) {
        result.message = "Nama yang dimasukkan terlalu pendek";
    } else if (!pattern.test(nm)) {
        result.message = "Hanya aksara & simbol ' ` @ - /. dibenarkan.";
    }
	else{
		result.valid = true;
	}
    return result;
}

//input in format: dd-MM-yyyy
function DatePicker_IsValidDate(input) {
	var bits = input.split('-');
	var d = new Date(bits[2], bits[1] - 1, bits[0]);
	return d.getFullYear() == bits[2] && (d.getMonth() + 1) == bits[1] && d.getDate() == Number(bits[0]);
}

function getTableData(tableName, rules) {
	if (typeof(rules)==='undefined') rules = 'tr';
    var table = $("#" + tableName);
	var data = [];
	table.find(rules).each(function (rowIndex, r) {
		var cols = [];
		$(this).find('th,td').each(function (colIndex, c) {
			cols.push(c.textContent);
		});
		data.push(cols);
	});
    return data;
}

function getCurrentScriptName()
{
	var url = window.location.pathname;
	var filename = url.substring(url.lastIndexOf('/')+1);
	return filename.substring(0, filename.lastIndexOf('.'));
}

//GENERAL FUNCTION
$('.select2').select2({ width: '100%' }); 

$.sessionTimeout({
	message: 'Sesi anda akan tamat dalam masa 1 minit.',
	keepAlive: false,
	keepAliveButton: 'Kekalkan sesi',
	keepAliveUrl: $('#footerIndexLink').val(),
	logoutUrl: $('#footerLogoutLink').val(),
	redirUrl: $('#footerLogoutLink').val(),
	warnAfter: 100000000,
	redirAfter: 120000000
});

/*
$('.modal-btn').click(function(){
	var url = $(this).attr('href');
	var target = $(this).attr("data-target");
	$(target + '_content').empty();
	//alert(url);
	$(target + '_content').load(url,function(result){
		$(target).modal({show:true});
	});
});
*/

function loadMyModal(url, target)
{
	$(target + '_content').empty();
	$(target + '_content').load(url,function(result){
		$(target).modal({show:true});
	});
}

$('.kp_tb, .numonly, #borang_kpbaru_semakan, #borang_kpbaru_semakan2').keypress(function(evt){
	evt = (evt) ? evt : window.event;
	var charCode = (evt.which) ? evt.which : evt.keyCode;
	if ((charCode >= 48 && charCode <= 57)) {
		return true;
	}
	return false;
});

function printTable(tableName, title, printType, printPath, landscapeProtrait="L")
{
	var dataObject = [];
	dataObject['title'] = title;
	dataObject['printType'] = printType;
	dataObject['landscapeProtrait'] = landscapeProtrait;
	var table = $("#" + tableName);
	var data = [];
	table.find('tr').each(function (rowIndex, r) 
	{
		var cols = [];
		$(this).find('th,td').each(function (colIndex, c) {
			var extraStyle = '';
			var myClass = c.getElementsByClassName("colorClass");
			if(myClass.length > 0)
			{
				extraStyle = '<style>' + myClass[0].getAttribute("style");
			}
			cols.push(c.innerText + extraStyle);
		});
		data.push(cols.join('|'));
	});
	dataObject['data'] = data.join('|BRE|');
	post(printPath, dataObject);
}

function initTable(tableName, ajaxURL, ajaxData, orderIndex, bilIndex, notSearchableColumns, specialCase, notOrderableColumns, table_searchable)
{ 
	if (typeof(orderIndex)==='undefined') orderIndex = 0;
	if (typeof(bilIndex)==='undefined') bilIndex = -1;
	if (typeof(notSearchableColumns)==='undefined') notSearchableColumns = [-1];
	if (typeof(notOrderableColumns)==='undefined') notOrderableColumns = notSearchableColumns;
	if (typeof(specialCase)==='undefined') specialCase = 0;
	if (typeof(table_searchable)==='undefined') table_searchable = true;
	//if (typeof(hiddenColumn)==='undefined') hiddenColumn = [-999];
	
	if(bilIndex > -1)
	{
		notSearchableColumns.push(bilIndex);
	}
	
	var table = $('#' + tableName);
	var oTable = table.DataTable({
		
		//add these 3 lines
		"processing": true,
		"serverSide": true,
		"stateSave": true,
		"scrollX": true,
		"error": function(jqXHR, textStatus, errorThrown) {
			alert(textStatus); // this will be "timeout"
		},
		"ajax": {
			url:ajaxURL,
			type:"post",
			data:ajaxData,
			dataSrc: function ( json ) {
				return json.data;
			},
		},
		"searching": table_searchable,
		"columnDefs": [
			{ "searchable": false, "targets": notSearchableColumns },
			{ "orderable": false, "targets": notOrderableColumns },
			{
				targets: '_all',
				className: 'dt-center'
			}
		  ],
		"rowCallback": function( row, data, index) {
			if(bilIndex > -1)
			{
				var myApi = this.api();
				var page = myApi.page();
				var length = myApi.page.len();
				var myIndex = (page * length + (index +1));
				$('td:eq(' + bilIndex + ')', row).html( myIndex );
			}
			if(ajaxURL.includes("-list_ajax.php"))
			{
				if(data[14] == 2)
				{
					var datenow = moment();
					var send_date = moment(data[3], "YYYY-MM-DD hh:mm:ss");
					var daydiff = datenow.diff(send_date, 'days');
					var newHTML = '';
					newHTML = send_date.format('DD MMM YYYY') + '<br>(' + daydiff + ' hari)';
					
					if(daydiff > 10)
					{
						newHTML = '<span class="label label-lg font-weight-bold label-light-danger label-inline" style="height: 40px;">' + send_date.format('DD MMM YYYY') + '<br>(' + daydiff + ' hari)</span>';
						$(row).addClass('table-danger');
					}
					$('td:eq(3)', row).html( newHTML );
				}
			}
		},
		"initComplete": function(settings, json) {
		},
		"sPaginationType": "full_numbers",
		"bPaginate": true,

		"language": {
			"aria": {
				"sortAscending": ": activate to sort column ascending",
				"sortDescending": ": activate to sort column descending"
			},
			"emptyTable": "No data available in table",
			"info": "Papar _START_ hingga _END_ dari _TOTAL_ rekod",
			"infoEmpty": "Tiada Rekod",
			"infoFiltered": "",
			"lengthMenu": "Papar _MENU_ rekod",
			"search": "Carian:",
			"zeroRecords": "No matching records found",
		},
		
		"order": [
			[orderIndex, 'desc']
		],            

		"lengthMenu": [
			[5, 10, 20, 50, 100, 200, 500, 1000, 5000, 10000, -1],
			[5, 10, 20, 50, 100, 200, 500, 1000, 5000, 10000, "All"] // change per page values here
		],

		"pageLength": 20,
		"dom": "<'row' <'col-md-12'T>><'row'<'col-md-6 col-sm-12'l><'col-md-6 col-sm-12'f>r><'table-scrollable't><'row'<'col-md-5 col-sm-12'i><'col-md-7 col-sm-12'p>>", // horizobtal scrollable datatable

		"tableTools": {
			"sSwfPath": "assets/global/plugins/datatables/extensions/TableTools/swf/copy_csv_xls_pdf.swf",
			"aButtons": []
		},
		
	});
	
}

function reinitTable(tableName, ajaxURL, ajaxData, orderIndex, bilIndex, notSearchableColumns, specialCase, notOrderableColumns, table_searchable)
{
	if (typeof(orderIndex)==='undefined') orderIndex = 0;
	if (typeof(bilIndex)==='undefined') bilIndex = -1;
	if (typeof(notSearchableColumns)==='undefined') notSearchableColumns = [-1];
	if (typeof(notOrderableColumns)==='undefined') notOrderableColumns = notSearchableColumns;
	if (typeof(specialCase)==='undefined') specialCase = 0;
	if (typeof(table_searchable)==='undefined') table_searchable = true;
	
	var o_table = $('#' + tableName).DataTable();
	if(o_table)
	{
		o_table.destroy();
	}
	initTable(tableName, ajaxURL, ajaxData, orderIndex, bilIndex, notSearchableColumns, specialCase, notOrderableColumns, table_searchable);
}

function printFunc(tableName, value, phpUrl, baseName, title, header, getDataObj, printonlyheader, pageOrientation, subHeaderTitle)
{
	if (typeof(baseName)==='undefined') baseName = '';
	if (typeof(title)==='undefined') title = '';
	if (typeof(header)==='undefined') header = '';
	if (typeof(pageOrientation)==='undefined') pageOrientation = 'P';
	if (typeof(subHeaderTitle)==='undefined') subHeaderTitle = '';
	var o_table = $('#' + tableName).DataTable();
	var dataOption = o_table.ajax.params(); //get last ajax run params
	var arr = value.split(',');
	dataOption.printAll = arr[0]; //modify the printAll option
	dataOption.printType = arr[1]; //modify the printType option
	dataOption.baseName = baseName;
	dataOption.title = title;
	dataOption.header = header;
	dataOption.printonlyheader = printonlyheader;
	dataOption.pageOrientation = pageOrientation;
	dataOption.subHeaderTitle = subHeaderTitle;
	for (key in getDataObj)
	{
		dataOption[key] = getDataObj[key];
	}
	dataOption.sqlOnly = 1; //modify the sqlOnly option
	//dataOption.getDataObj = JSON.stringify(getDataObj);
	//console.log(getDataObj);
	console.log(dataOption);
	//var str = jQuery.param( dataOption );
	post(phpUrl, dataOption);
}

$('.myDatePicker').datepicker({
	autoclose: true,
	clearBtn: true,
	format: "dd-mm-yyyy",
	todayHighlight: true,
	orientation: "bottom left",
	templates: {
		leftArrow: '<i class="la la-angle-left"></i>',
		rightArrow: '<i class="la la-angle-right"></i>'
	}
});