243 lines
7.3 KiB
JavaScript
243 lines
7.3 KiB
JavaScript
|
$(document).on("click", ".break-otklic", function(event){
|
|||
|
var id = $(this).data('id');
|
|||
|
$.ajax({
|
|||
|
type: 'POST',
|
|||
|
url: '/act/quick-work',
|
|||
|
data: 'act=breakOtklic&id=' + id,
|
|||
|
success: function(data) {
|
|||
|
(function() {
|
|||
|
alert("Вы отменили выбор исполнителя, обновите страницу и можете выбрать нового!")
|
|||
|
})();
|
|||
|
}
|
|||
|
});
|
|||
|
$('.get-otklic').hide('1000');
|
|||
|
})
|
|||
|
|
|||
|
|
|||
|
//принимаем отклик
|
|||
|
|
|||
|
$(document).on("click", ".get-otklic", function(event){
|
|||
|
var id = $(this).data('id');
|
|||
|
$.ajax({
|
|||
|
type: 'POST',
|
|||
|
url: '/act/quick-work',
|
|||
|
data: 'act=getOtklic&id=' + id,
|
|||
|
success: function(data) {
|
|||
|
(function() {
|
|||
|
alert("Исполнитель выбран, ему доступны ваши контакты и он с вами обязательно свяжется!")
|
|||
|
})();
|
|||
|
}
|
|||
|
});
|
|||
|
$('.get-otklic').hide('1000');
|
|||
|
})
|
|||
|
|
|||
|
|
|||
|
|
|||
|
//показывает список откликнувшихся
|
|||
|
|
|||
|
$("#show-otklic").click(function(event) {
|
|||
|
$("#list-workers").text("");
|
|||
|
var id = $(this).data('id');
|
|||
|
var srv= $(this).data('srv');
|
|||
|
$.ajax({
|
|||
|
type: "POST",
|
|||
|
url: '/act/quick-work',
|
|||
|
data: "act=get-workers&id=" + id,
|
|||
|
dataType: 'json',
|
|||
|
success: function(data) {
|
|||
|
$.each(data, function(index, element) {
|
|||
|
if (element.isp=='1')
|
|||
|
var res = '<tr><td><a href="/user/' + element.user_id + '"><img src="/img/ava/' + srv + '/' + element.ava + '.jpg" style="width:100%;"></a></td><td><a href="/user/' + element.user_id + '" style="color: black;">' + element.fio + '</a><p>Рейтинг: ' + element.repa + '</p><p>Предложение: ' + element.cena + '</p><button type="button" class="btn btn-primary break-otklic" data-id="' + element.id + '">Отменить</button></td></tr>';
|
|||
|
else
|
|||
|
var res = '<tr><td><a href="/user/' + element.user_id + '"><img src="/img/ava/' + srv + '/' + element.ava + '.jpg" style="width:100%;"></a></td><td><a href="/user/' + element.user_id + '" style="color: black;">' + element.fio + '</a><p>Рейтинг: ' + element.repa + '</p><p>Предложение: ' + element.cena + '</p><button type="button" class="btn btn-primary get-otklic" data-id="' + element.id + '">Принять</button></td></tr>';
|
|||
|
$("#list-workers").append(res);
|
|||
|
})
|
|||
|
}
|
|||
|
});
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
})
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
//Откликашка
|
|||
|
$("#work-otklic").click(function(event) {
|
|||
|
var id=$(this).data('id');
|
|||
|
var cena=$("#o-cena").val();
|
|||
|
$.ajax({
|
|||
|
type: "POST",
|
|||
|
url: '/act/quick-work',
|
|||
|
data: "act=otklick&id=" + id + "&cena=" + cena,
|
|||
|
success: function(data) {
|
|||
|
|
|||
|
}
|
|||
|
});
|
|||
|
|
|||
|
|
|||
|
|
|||
|
$(this).text("OK!");
|
|||
|
|
|||
|
})
|
|||
|
|
|||
|
|
|||
|
|
|||
|
$("#form-zakaz").submit(function(event) {
|
|||
|
|
|||
|
event.preventDefault();
|
|||
|
var formData = new FormData(this);
|
|||
|
$.ajax({
|
|||
|
type: 'POST', // Тип запроса
|
|||
|
url: '/act/quick-work', // Скрипт обработчика
|
|||
|
data: formData, // Данные которые мы передаем
|
|||
|
cache: false, // В запросах POST отключено по умолчанию, но перестрахуемся
|
|||
|
contentType: false, // Тип кодирования данных мы задали в форме, это отключим
|
|||
|
processData: false,
|
|||
|
success: function(data) {
|
|||
|
//location="/quick-work/" + data;
|
|||
|
}
|
|||
|
});
|
|||
|
$("work-result").removeClass('hidden');
|
|||
|
|
|||
|
})
|
|||
|
|
|||
|
|
|||
|
$("#public_work").click(function(event) {
|
|||
|
$("#form-zakaz").submit();
|
|||
|
})
|
|||
|
|
|||
|
|
|||
|
$("#new_work").click(function(event) {
|
|||
|
$.ajax({
|
|||
|
type: "POST",
|
|||
|
url: '/act/quick-work',
|
|||
|
data: "act=new_work",
|
|||
|
success: function(data) {
|
|||
|
// $("#work_id").val(id);
|
|||
|
}
|
|||
|
});
|
|||
|
$("#hidden-dialog").removeClass('hidden');
|
|||
|
})
|
|||
|
|
|||
|
|
|||
|
|
|||
|
$('.popup-content').magnificPopup({
|
|||
|
type: 'inline'
|
|||
|
});
|
|||
|
|
|||
|
/* -- uploader -- */
|
|||
|
|
|||
|
// ************************ Drag and drop ***************** //
|
|||
|
let dropArea = document.getElementById("drop-area")
|
|||
|
|
|||
|
// Prevent default drag behaviors
|
|||
|
;
|
|||
|
['dragenter', 'dragover', 'dragleave', 'drop'].forEach(eventName => {
|
|||
|
dropArea.addEventListener(eventName, preventDefaults, false)
|
|||
|
document.body.addEventListener(eventName, preventDefaults, false)
|
|||
|
})
|
|||
|
|
|||
|
// Highlight drop area when item is dragged over it
|
|||
|
;
|
|||
|
['dragenter', 'dragover'].forEach(eventName => {
|
|||
|
dropArea.addEventListener(eventName, highlight, false)
|
|||
|
})
|
|||
|
|
|||
|
;
|
|||
|
['dragleave', 'drop'].forEach(eventName => {
|
|||
|
dropArea.addEventListener(eventName, unhighlight, false)
|
|||
|
})
|
|||
|
|
|||
|
// Handle dropped files
|
|||
|
dropArea.addEventListener('drop', handleDrop, false)
|
|||
|
|
|||
|
function preventDefaults(e) {
|
|||
|
e.preventDefault()
|
|||
|
e.stopPropagation()
|
|||
|
}
|
|||
|
|
|||
|
function highlight(e) {
|
|||
|
dropArea.classList.add('highlight')
|
|||
|
}
|
|||
|
|
|||
|
function unhighlight(e) {
|
|||
|
dropArea.classList.remove('active')
|
|||
|
}
|
|||
|
|
|||
|
function handleDrop(e) {
|
|||
|
var dt = e.dataTransfer
|
|||
|
var files = dt.files
|
|||
|
|
|||
|
handleFiles(files)
|
|||
|
}
|
|||
|
|
|||
|
let uploadProgress = []
|
|||
|
let progressBar = document.getElementById('progress-bar')
|
|||
|
|
|||
|
function initializeProgress(numFiles) {
|
|||
|
progressBar.value = 0
|
|||
|
uploadProgress = []
|
|||
|
|
|||
|
for (let i = numFiles; i > 0; i--) {
|
|||
|
uploadProgress.push(0)
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
function updateProgress(fileNumber, percent) {
|
|||
|
uploadProgress[fileNumber] = percent
|
|||
|
let total = uploadProgress.reduce((tot, curr) => tot + curr, 0) / uploadProgress.length
|
|||
|
console.debug('update', fileNumber, percent, total)
|
|||
|
progressBar.value = total
|
|||
|
}
|
|||
|
|
|||
|
function handleFiles(files) {
|
|||
|
files = [...files]
|
|||
|
initializeProgress(files.length)
|
|||
|
files.forEach(uploadFile)
|
|||
|
files.forEach(previewFile)
|
|||
|
}
|
|||
|
|
|||
|
function previewFile(file) {
|
|||
|
let reader = new FileReader()
|
|||
|
reader.readAsDataURL(file)
|
|||
|
reader.onloadend = function() {
|
|||
|
let img = document.createElement('img')
|
|||
|
img.src = reader.result
|
|||
|
document.getElementById('gallery').appendChild(img)
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
function uploadFile(file, i) {
|
|||
|
var url = '/act/quick-work'
|
|||
|
var xhr = new XMLHttpRequest()
|
|||
|
var formData = new FormData()
|
|||
|
xhr.open('POST', url, true)
|
|||
|
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest')
|
|||
|
|
|||
|
// Update progress (can be used to show progress indicator)
|
|||
|
xhr.upload.addEventListener("progress", function(e) {
|
|||
|
updateProgress(i, (e.loaded * 100.0 / e.total) || 100)
|
|||
|
})
|
|||
|
|
|||
|
xhr.addEventListener('readystatechange', function(e) {
|
|||
|
if (xhr.readyState == 4 && xhr.status == 200) {
|
|||
|
updateProgress(i, 100) // <- Add this
|
|||
|
} else if (xhr.readyState == 4 && xhr.status != 200) {
|
|||
|
// Error. Inform the user
|
|||
|
}
|
|||
|
})
|
|||
|
|
|||
|
formData.append('upload_preset', 'ujpu6gyk')
|
|||
|
formData.append('act', 'upload')
|
|||
|
formData.append('file', file)
|
|||
|
xhr.send(formData)
|
|||
|
}
|
|||
|
|
|||
|
/* ----------------------------------------------------------------------
|
|||
|
15.10.2022
|
|||
|
Селект
|
|||
|
---------------------------------------------------------------------- */
|
|||
|
$("#sel-children-city").chained("#sel-parent-region");
|