| Server IP : 65.108.144.40 / Your IP : 216.73.217.165 Web Server : Apache/2.4.52 (Ubuntu) System : Linux ubuntu-8gb-hel1-1 5.15.0-173-generic #183-Ubuntu SMP Fri Mar 6 13:29:34 UTC 2026 x86_64 User : dev ( 1000) PHP Version : 8.2.30 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/erp/static/src/period/ |
Upload File : |
$(document).ready(function () {
// this function is used to generate csrf token
function getCookie(name) {
let cookieValue = null;
if (document.cookie && document.cookie !== "") {
const cookies = document.cookie.split(";");
for (let i = 0; i < cookies.length; i++) {
const cookie = cookies[i].trim();
// Does this cookie string begin with the name we want?
if (cookie.substring(0, name.length + 1) === (name + "=")) {
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
break;
}
}
}
return cookieValue;
}
$select = $("#id_period").select2({
minimumResultsForSearch: -1,
}).on("change", function () {
let $this = $(this)
periodChange($this)
});
$select.data('select2').$selection.addClass('oh-select--lg--custom'); //adding css class for the select
// period assigning to dates
function periodChange(period_data) {
var period_id = period_data.val()
$.ajax({
url: '/pms/period-change',
type: "POST",
dataType: "json",
data: JSON.stringify(period_id),
headers: {
"X-Requested-With": "XMLHttpRequest",
"X-CSRFToken": getCookie("csrftoken"),
},
success: (data) => {
// adding data to start and end date
$('#id_start_date').val(data.start_date)
$('#id_end_date').val(data.end_date)
},
error: (error) => {
console.log('Error', error);
}
})
}
});